03-25-2012 03:24 PM
We have an app that runs on android that we are trying to port over using the android runtime for blackberry.
We have some sounds that play intermittently when the app is running, and because of this we found out that the runtime doesn't really follow Android behavior on Activity state changes when the power button is pressed or the playbook times out and turns off the screen.
We expected that when the playbook goes into suspend mode or the power button is turned off, "onPause" for the running android activity would be called, but it does not. Even "onWindowFocusChnged" is not called.
Does anyone know what chnge in state Is called when the power button is pressed? Is there any way to detect whether the user has pressed the power button in the runtime?
Thanks for any help.
04-04-2012 03:35 AM - edited 04-04-2012 03:36 AM
Sorry to bump this thread, but can anyone confirm that they do indeed see an activity state change when the power button is pressed while your activity is running?
When I press the power button on mine, the screen turns off but onWindowFocusChanged, onPause, onKeyDown, onStop all are *not* called. Is there another method I should be overriding to see this change? I would really like to pause my game when the user presses the power button but since my activity can't detect any change, I can't tell my game to pause.
I see in the logcat:
04-04 00:31:59.195: D/QNXNavigatorClient(83476610): onActive: active=false, group-id=pb-android-player-application-window
04-04 00:31:59.256: D/QNXNavigatorClient(83476610): onWindowState: state=invisible, group-id=pb-android-player-application-window
04-04 00:31:59.268: D/Lowmemorykiller(83382389): android_monitor_thread: window state changed to 0
04-04 00:31:59.268: D/QNXNavigatorClient(83476610): Screen off
04-04 00:31:59.285: D/wifi(83476610): status: wifi-state=7
04-04 00:32:02.392: D/QNXNavigatorClient(83476610): onActive: active=true, group-id=pb-android-player-application-window
04-04 00:32:02.424: D/QNXNavigatorClient(83476610): onWindowState: state=fullscreen, group-id=pb-android-player-application-window
04-04 00:32:02.436: D/Lowmemorykiller(83382389): android_monitor_thread: window state changed to 2
04-04 00:32:02.448: D/QNXNavigatorClient(83476610): Screen on
But nothing from my Activity. Can I set up a listener for the QNXNavigatorClient's events in my activity??
If anyone even hasn't encountered this problem, I'd love to hear back, just to see whether something is wrong with my activity or playbook or android runtime... Any help one way or the other is really appreciated!
04-05-2012 07:44 AM
04-05-2012 01:52 PM - edited 04-05-2012 01:52 PM
I've looked deeply into the problem.
If the Android app has high CPU usage it will miss onPause() and onResume() calls when standby hardware button is pressed. If the CPU usage is low both onPause() and onResume() methods are being called. Looks like some messages are not propagated to or by Android Player under high load.
That will lead Android apps which has high CPU usage not to stop when standby button is pressed by user. That will lead to battery drain and unwanted traffic consumption (if the app was consuming traffic).
I've created a new bug report:
[Android] Activity change methods are not called when standby button is pressed on high CPU usage - potential battery drain
https://www.blackberry.com/jira/browse/TABLET-555
Vote for this bug to speedup BB guys to fix it. I think this is a critical issue. Maybe that's why battery life is so low on BB Playbook.
04-05-2012 02:19 PM - edited 04-05-2012 02:28 PM
Thanks for confirming; I was able to reproduce the problem last night in the lunarlander sample if I pegged the cpu in a similar fashion to your sample, so I'm glad to hear my findings are consistent.
I've voted up the issue, but at least now I can work on lowering CPU usage and hope to work around the bug.
04-10-2012 03:08 AM
The bug report has been closed with the description: "This has been fixed in BlackBerry Tablet OS 2.0.1."
04-09-2013 09:33 PM - edited 04-09-2013 09:34 PM
Whatever was fixed was not done correctly for BB10.
Activity onStop method is being called when pwer button is pressed. Should just call onPause like the other 10,000 models of Android devices available. If resoursces are low only then should onStop, onDestroy get called.
Just call onPause.
Also, in current form no way for Activity to distinuish between powerbutton click (user wants to turn off screen but will likely return to same activity) and minimiize gesture (swipe up from bottom).
In both cases on Z10 device, the following is called:
onUseLeaveHint
onPause
onStop.
Clearly the the actions screen timeout/ power button click are different than minimize gesture, but Android runtime treats the same. BUG.
04-10-2013 02:50 AM
04-10-2013 10:36 AM
alexvas wrote:
Please submit the issue to JIRA
https://www.blackberry.com/jira/
Already done:
Search for onStop and you'll find it. Didn't see anyway to copy past a real link from JIRA. Please upvote