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

Native Development

Reply
Developer
rmisk
Posts: 64
Registered: ‎02-21-2012
My Device: Blackberry Playbook

Running app while in standby mode

I would like to record some sensor data while in standby mode.  I am using Native SDK 2.0 C/C++ and haven't found anything that works when in standby in the same way the Music player does.

 

I have tried:

 

int idle_mode = SCREEN_IDLE_MODE_KEEP_AWAKE;

screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_IDLE_MODE, &idle_mode);

 

which builds okay but does not seem to have any effect.

 

Any guidance would be much appreciated.

 

Roger

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Running app while in standby mode

Keep awake is useful only when the app is "active". I don't know what this might mean with native apps, but for AIR (and probably all apps) it means either you have Showcase on (all apps "active"), or Default mode with your app visible (fullscreen or thumbnailed), or Paused mode with your app fullscreen.

That's not really the API you want to use for this, however, if there's an alternative, as keeping the screen on uses lots more power than having it off.

Unfortunately, it's quite possible there are no alternatives at this time since there's no love given yet to background services or apps which want to do useful things will in standby, like log GPS locations periodically.

Maybe it works for some sensors... which ones are you trying? For now, it won't work for GPS.

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
rmisk
Posts: 64
Registered: ‎02-21-2012
My Device: Blackberry Playbook

Re: Running app while in standby mode

Peter, thank you for your reply.

 

Geolocation is exactly the one I wanted to use.  Is there a way to programmatically adjust the brightness so I leave the application full screen but dim it until black or near black?

 

Roger

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Running app while in standby mode

Unfortunately, also no API for that yet either.

If you want to minimize power consumption (which you'd think RIM would want to let us do by providing the ability to run GPS with the screen OFF rather than forcing us to use KEEP_AWAKE and have it stay on, just to let GPS run), be sure to keep your screen contents on the "dark" side.

Running with an all-white screen uses something like 0.5W *more* power than having an all-black screen. Buy Battery Guru to make your own measurements if you need more detail. ;-)

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
rmisk
Posts: 64
Registered: ‎02-21-2012
My Device: Blackberry Playbook

Re: Running app while in standby mode

Until I learn more about using windows I am just using the dialog to present text data ...

 

I suppose there is no way to change the background and text colour in a dialog?

Developer
rmisk
Posts: 64
Registered: ‎02-21-2012
My Device: Blackberry Playbook

Re: Running app while in standby mode

[ Edited ]

Just purchased Battery Guru, it looks really good.

 

Did you develop it using native SDK?  If not what did you use?

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Running app while in standby mode

Thanks, yes I did. (See my signature lines, if you haven't disabled signatures in this forum.)

It's an AIR app, from last May when we had no other useful options. I'll redo as a Qt app (Cascades) once the libraries are ready to be supported pre-installed on the platform (or the size will balloon to 15MB or so!).

There's likely no way to modify those characteristics of the dialogs. Note that they are not actually running inside your app, but are provided by a separate service (controlled, I believe, by the sys.systemtray app which also runs the status bar etc). You have limited control over them, which likely explains most of what you're seeing.

If you're trying to get past an inability to display stuff onscreen easily, I suggest moving over to investigate Qt for a bit. This is where the activity is for most non-game apps, and while it's very much a work in progress, it's reached the point people are doing useful things with it (even submitting some apps for the free PlayBook offer than just ended). The upcoming "Cascades" UI stuff you may have heard of is based directly on that, so any learning you do is unlikely to be wasted, and you'll gain the ability to directly show your text and stuff onscreen without resorting to the limited dialog approach.

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
rmisk
Posts: 64
Registered: ‎02-21-2012
My Device: Blackberry Playbook

Re: Running app while in standby mode

 

This:

 

int idle_mode = SCREEN_IDLE_MODE_KEEP_AWAKE;

screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_IDLE_MODE, &idle_mode);

 

worked once or twice after I restarted the Playbook.

 

I had assumed that all I needed to do was include that once near the beginning of the code but I found it works reliably (so far) if I put in the main loop so that it is constantly executed/refreshed.

 

This isn't what I expected.  Is there any documentation saying how it works and where it should be implemented?

 

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Running app while in standby mode

Keep awake needs the window to be visible. Are you making sure that's the case when you're doing it? If you bring up another app, the setting in your app has no effect.

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
rmisk
Posts: 64
Registered: ‎02-21-2012
My Device: Blackberry Playbook

Re: Running app while in standby mode

Yes, when it wasn't working I had the single app running full screen.  To fix it I had to keep refreshing the KEEP_AWAKE.  I am guessing by your comment you don't  do that in Battery Guru?