Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Development

Reply
New Contributor
Posts: 5
Registered: ‎02-08-2012
My Device: PlayBook 2.0 Simulator
My Carrier: n/a

Activity state when power button is pressed or times out

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.

New Contributor
Posts: 5
Registered: ‎02-08-2012
My Device: PlayBook 2.0 Simulator
My Carrier: n/a

Re: Activity state when power button is pressed or times out

[ Edited ]

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!

Contributor
Posts: 15
Registered: ‎03-16-2012
My Device: Q10, Z10
My Carrier: n/a

Re: Activity state when power button is pressed or times out

This is a bug in Android player. It does not propagate power events to Android apps. I have the same issue with my apps.

I will create a bug report. This bug leads to Playbook battery drain.
Contributor
Posts: 15
Registered: ‎03-16-2012
My Device: Q10, Z10
My Carrier: n/a

Re: Activity state when power button is pressed or times out

[ Edited ]

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.

Highlighted
New Contributor
Posts: 5
Registered: ‎02-08-2012
My Device: PlayBook 2.0 Simulator
My Carrier: n/a

Re: Activity state when power button is pressed or times out

[ Edited ]

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.

Contributor
Posts: 15
Registered: ‎03-16-2012
My Device: Q10, Z10
My Carrier: n/a

Re: Activity state when power button is pressed or times out

The bug report has been closed with the description: "This has been fixed in BlackBerry Tablet OS 2.0.1."

Regular Contributor
Posts: 84
Registered: ‎01-31-2013
My Device: Simulator !!!
My Carrier: 8608800458

Re: Activity state when power button is pressed or times out

[ Edited ]

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.

 

Contributor
Posts: 15
Registered: ‎03-16-2012
My Device: Q10, Z10
My Carrier: n/a

Re: Activity state when power button is pressed or times out

Please submit the issue to JIRA
https://www.blackberry.com/jira/
New Developer
Posts: 6
Registered: ‎09-19-2008
My Device: Not Specified

Re: Activity state when power button is pressed or times out


alexvas wrote:
Please submit the issue to JIRA
https://www.blackberry.com/jira/

Already done: 

BB10 Android runtime power button click should not call Activity onStop method

 

Search for onStop and you'll find it. Didn't see anyway to copy past a real link from JIRA. Please upvote