[英]Android:Unlock Screen
I am able to unlock the screen when there is an incoming call and after that lock the screen again. 当有来电时,我可以解锁屏幕,然后再锁定屏幕。 After a restart of the device if I get first incoming call this logic is not working. 重新启动设备后,如果我收到第一个来电,则此逻辑不起作用。 On subsequent incoming calls the logic works. 在随后的来电中,逻辑起作用。
Any help?? 有帮助吗?
My code is: 我的代码是:
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (state.contentEquals("RINGING")) {
lock.disableKeyguard();
}
lock.reenableKeyguard();
It seems to me that your "lock" object does not exist until the first call is made but I can't tell by looking at that piece of code. 在我看来,您的“锁定”对象在进行第一次调用之前并不存在,但是通过查看这段代码我看不出来。
I use windowmanager to unlock and lock my screen. 我使用windowmanager解锁和锁定屏幕。
Window window = getWindow();
WindowManager.LayoutParams windowParams = window.getAttributes();
winParams.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
window.setAttributes(winParams);
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html
hope this helps 希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.