Join now - be part of our community!

Screen lock (keyguard) not always working

skela
Visitor

Screen lock (keyguard) not always working

When I use the clock application (the one that shows 4 icons on the bottom of the screen: alarm settings, pictures, music, home screen) the screen lock button will only blank the screen. Pressing it again will bring back the clock application. I guess that this is done on purpose, so that the phone can be used as a clock, so that you can quickly check the time when you wake up in the middle of the night.

However, when I make a phone call, hang up and push the screen lock button, there seems to be a bug. When I push the button again, I will not get the lock screen nor the phone application screen, but the home screen! This could lead to ‘pocket calls’. Only after pressing the screen lock button a third time will the lock screen be activated.

Finally, a programming question (sorry, maybe a bit off-topic here). I am thinking of developing my own ANT+Sport based bicycle computer application. (Sorry Ifor, while IpBike looks interesting, I prefer open source.) I would have the phone in the SportyPal mount on the handlebars. To save battery time, I would keep the screen blanked most of the time. But, when I hit the screen lock button, I would like to see my application screen with all the relevant data, instead of having to unlock the phone first. How can this be achieved? Is it by using the DISABLE_KEYGUARD permission and the deprecated android.app.KeyguardManager.KeyguardLock methods, or by simply using the window attribute FLAG_DISMISS_KEYGUARD?

1 REPLY 1
skela
Visitor

The solution to my programming question is to do the following in Activity.onCreate():

getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

This does not seem to require any special permissions. The screen will go black when I push the power/lock button, and the application screen will come back when I push the power/lock button again.

I guess that the dialer application is controlling this flag (or similar flag) dynamically, and the bug there is that it does not clear the flag immediately after you hang up a call (when the call information screen is visible), but only after it returns to the previous screen, such as the call log, from which the call was initiated. I was wrong in my initial post; it seems that the power/lock button will bring back the dialer application, not the home screen.

By the way, my firmware version 4.0.2.A.0.62 (Android 2.3.4).