开发者

Android:Unlock Screen

开发者 https://www.devze.com 2023-04-12 04:51 出处:网络
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 in

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.

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

hope this helps

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号