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

Adobe AIR Development

Reply
Contributor
Posts: 32
Registered: ‎02-02-2011
My Device: Playbook
My Carrier: none
Accepted Solution

InactivePowerMode in OS 2.0 Not Working

I have a cooking timer app with the option to disable audio alarms and popups when the app is in the background.

 

I was using ACTIVATE and DEACTIVATE events and inactivePowerMode set to throttled.

 

This is no longer working for me in OS 2.0 using SDK 2.0 UNLESS the user sets up the playbook to:

Settings>General>Application Behavior>Paused.

 

In the docs for the bar-descriptor.xml (blackberry-tablet.xml) file

https://bdsc.webapps.blackberry.com/air/documentation/ww_air_developing/Configuring_your_application...

There is no mention of inactivePowerMode.

I can still package my app with this line without any errors:

<inactivePowerMode>throttled</inactivePowerMode>

But it is doesn't seem to have any effect.

 

So I tried this in my app code:

 

import qnx.system.QNXSystem;
import qnx.system.QNXSystemPowerMode;
QNXSystem.system.powerMode = QNXSystemPowerMode.THROTTLED;

 

This code causes my app to freeze at the splash screen on my device.

 

So how about this:

http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/Power-Management-Application-and-...

 

var win:IowWindow = IowWindow.getAirWindow();
win.addEventListener(IowWindowEvent.WINDOW_STATE_CHANGED, stateChanged );

function stateChanged(event:IowWindowEvent):void {
	switch( win.state ) {
		case IowWindowState.NORMAL:
			trace( "app is full screen" );
			break;
		case IowWindowState.THUMBNAIL:
			trace( "app is minimized" );
			break;
		case IowWindowState.HIDDEN:
			trace( "app is hidden" );
			break;
	}
}

Is this my only recourse? I'm not really dying to rewrite my code everytime a new update comes out from blackberry.

 

--------------------------------------
Dirty Kitchen Cooking Timer
http://appworld.blackberry.com/webstore/content/37403
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: InactivePowerMode in OS 2.0 Not Working

I don't remember the specifics of what changed, but I believe that with the changes in 2.0 you should now be using the latter approach.

This was, I'm fairly certain, all the same in the betas (at least, in the last few).

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Contributor
Posts: 32
Registered: ‎02-02-2011
My Device: Playbook
My Carrier: none

Re: InactivePowerMode in OS 2.0 Not Working

Thanks for your reply. I did realize after more testing that using:

<inactivePowerMode>throttled</inactivePowerMode>

 inside the bar-descriptor.xml file is still essential. It doesn't effect the app when it is pushed into the background, but it does effect the app when the playbook is in standby. My alarm will not sound when the playbook is in standby without this line intact.

 

Blackberry has dropped inactivePowerMode from the docs for the bar-descriptor.xml file. Hopefully they will put it back in. This is an important one!

--------------------------------------
Dirty Kitchen Cooking Timer
http://appworld.blackberry.com/webstore/content/37403
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: InactivePowerMode in OS 2.0 Not Working

There's actually an API in the qnx.* namespace somewhere to do the same thing that the <inactivePowerMode> XML entry accomplished, but it's better because you can change it on and off as required.

My guess is that this was removed from the XML file since it applies only to AIR apps anyway, and they want that file to be consistent across each development environment.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: InactivePowerMode in OS 2.0 Not Working

For reference, see this background article which, I believe, has been updated for the changes: http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/Power-Management-Application-and-...

 

Also, for anyone else reading: https://bdsc.webapps.blackberry.com/air/apis/qnx/system/QNXSystem.html and https://bdsc.webapps.blackberry.com/air/apis/qnx/system/QNXSystemPowerMode.html contain the API docs for the relevant items.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Contributor
Posts: 32
Registered: ‎02-02-2011
My Device: Playbook
My Carrier: none

Re: InactivePowerMode in OS 2.0 Not Working

As stated in my first post:

import qnx.system.QNXSystem;
import qnx.system.QNXSystemPowerMode;
QNXSystem.system.powerMode = QNXSystemPowerMode.THROTTLED;

 Is crashing my app.

--------------------------------------
Dirty Kitchen Cooking Timer
http://appworld.blackberry.com/webstore/content/37403
Highlighted
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: InactivePowerMode in OS 2.0 Not Working

That could be, but note that you probably shouldn't be playing with powerMode directly for this purpose anyway. You want, I think, QNXSystem.system.inactivePowerMode. Setting that to THROTTLED should be identical to what you were getting from the XML entry.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!