Two taps to shutdown when using ReleaseKeepAlive
I have tried this method but there is one side effect my users are seeing that I have verified.
With my app on screen if you tap the power button the screen turns off for a second or so and then comes back on to the lock screen. So you need to tap the power button twice to force off the screen.
If I comment out just the ReleaseKeepAlive in the Activity_Pause then tapping the power button turns off and keeps off the screen. But you need to exit my app to force a Release of the Keep Alive.
Seems that a tap of the power button does not allow enough time for the ReleaseKeepAlive to get processed by the system so it wakeup turning on the screen to finish processing. I see an Activity_Create (FirstTime=false) right have the Activity_Pause. I don't see Activity_Create if I comment out the ReleaseKeepAlive in Activity_Pause.
I have a Bluetooth Serial link active. Is that causing a problem? Do I need to suspend it some how?
Here is a log of activity for the good case (switch away from app then tap power and bad case tap power while app on screen)
** Activity (main) Create, isFirst = false **
Activity_Create
Broadcast_Init
BroadcastReceiver has been initialized.
running waiting messages (1)
BtSerical_Connected
** Activity (main) Resume **
Activity_Resume
BtSerical_Connected
(At this point I used back key to switch away from app)
** Activity (main) Pause, UserClosed = true **
Activity_Pause
(Tap power button now and screen would turn off)
(Instead I switched back to app)
** Activity (main) Create, isFirst = false **
Activity_Create
Broadcast_Init
BroadcastReceiver has been initialized.
** Activity (main) Resume **
Activity_Resume
(Tap power button )
** Activity (main) Pause, UserClosed = false **
Activity_Pause
(Screen turned off but a second or so later it comes back on to lock screen)
(Note UserClosed=false)
(Why am I getting this Create?)
(Don't get it if I comment out ReleaseKeepAlive in Activity_Pause)
** Activity (main) Create, isFirst = false **
Activity_Create
Broadcast_Init
BroadcastReceiver has been initialized.
** Activity (main) Resume **
Activity_Resume
BtSerical_Connected
** Activity (main) Resume **
WakeLock already held.
Activity_Resume
(Second tap now the display turns off)
** Activity (main) Pause, UserClosed = false **
Activity_Pause