我试图在屏幕关闭的同时禁用锁定屏幕,但屏幕关闭后再次锁定。
我使用下面的代码来禁用锁定屏幕:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
} else {
KeyguardManager km = (KeyguardManager) activity.getSystemService(KEYGUARD_SERVICE);
kl = km.newKeyguardLock("name");
kl.disableKeyguard();
}
启用锁定屏幕:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
} else {
KeyguardManager km = (KeyguardManager) activity.getSystemService(KEYGUARD_SERVICE);
kl = km.newKeyguardLock("name");
kl.reenableKeyguard();
}
答案 0 :(得分:1)
在活动的OnCreate中尝试此操作。
console.log((<HTMLInputElement>document.getElementById('char').textContent))
答案 1 :(得分:0)
请在android.manifest.xml
中提供以下权限<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
您也可以参考此链接获取更多信息
https://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/