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
Regular Contributor
Posts: 84
Registered: ‎01-31-2013
My Device: Simulator !!!
My Carrier: 8608800458

Re: Can't receive Location updates if screen is off !!!

Latest testing on Z10 shows that if I hold a PARTIAL_WAKE_LOCK when user clicks power button, then after 15 minutes, the entire application gets killed. So even worse than before.This really needs to get re-evaluated. Do you have a work around that will let an Activity receive location updates or at least let Location Manager maintain a GPS lock when screen is off? Again on all other Android devices this is possible.

On other devices, onPause not onStop is called when user clicks power and location updates continue. This is without a wake lock.

If user clicks power button but does not exit the application then user indicates they want the application to continue to function and they will return to it (this is especially true for any navigation or GPS based application). All other Android devices let applications run in the background and BB10 native apps are able to use Active Frames for this as well.

What do you think?

04-22 18:03:21.441: W/ActivityManager(11919571): Excessive wake lock in com.goldsteintech.testproj (pid 14635224): held 900002 during 900002
...
04-22 18:03:21.479: I/ActivityManager(11919571): Process com.goldsteintech.testproj (pid 14635224) has died.
04-22 18:03:21.481: I/WindowManager(11919571): WIN DEATH: Window{7a608130 com.goldsteintech.testproj/com.goldsteintech.testproj.MainActivity paused=false}


Retired
Posts: 140
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Can't receive Location updates if screen is off !!!

That excessive wake lock warning and subsequent termination of your process is something that's baked into Android.  You definitely don't want to hold a partial wake lock indefinitely, so much so that Android attempts to curb your attempts to do so.

 

I will have to dig into this a bit more. 

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

Re: Can't receive Location updates if screen is off !!!

Ok, but you see the delima right?

 

As of right now BB10 offers no way to get Location Updates if the screen is off ( except for 15 minutes after which app is terminated). So I might be able to use the 15 minute window (if that is fixed) to get location updates during that time, then release the wake lock at minute 14 or something so the app doesn't get killed.

 

BB10 needs a way for Android apps to get location updates if user turns off the screen. Many use cases for this and it works without special handling or partial wake lock on other Android devices. 

 

Think of any Geo Caching or Navigation app, or my golf app. People keep the app open for long periods of time but want to conserve battery power and prevent button clicks with phone in their pocket, so they click power button to lock the screen. They want the app to keep getting location updates especially so that it doesn't have to re-acquire a satellite lock everytime the app is opened. It's a major feature of Andoid (not to mention iOS) that this is possible and is what has led to the success of those platforms.

 

I'm still hoping you can come up with some magic workaround but if not please open a defect ASAP. We need a way to do this.

 

Retired
Posts: 140
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Can't receive Location updates if screen is off !!!

There is no work around besides the partial wake lock that I mentioned. 

 

I'm still not convinced that the way that it's implemented now is incorrect (althought it might be a tad undiscoverable).  But if it's incorrect then surely it could be addressed.

 

Can you point me to some Android documentation that states that the GPS / CPU will remain on indefinitely as long as you have an active listener?

 

Does your app work as you intend if you turn all other radios off (my best guess at what might keep the CPU awake).

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

Re: Can't receive Location updates if screen is off !!!

I'll search for some official documentation, it may not be spelled out exactly though.  However I know this:

 

On all other Android devices, onPause not onStop is called when user clicks power button or screen times out. On BB10 onStop is called. On other devices onStop might eventually get called if device is low on resources, but this rarely happens.

 

On other devices Activity will continue to receive location updates for long period of time (30 minutes or more) while activity is paused (screen is off). Not the case on BB10, where location updates stop immediately.

 

BB10 doesn't allow the use of Android Service so can't use that to run in the background either.

 

So essentially no way for a BB10 Android app to do anything with locations while screen is off (with the exception of the 15 minute window). This is untrue for all other Android devices. So really hampers what you can do on BB10 from an Android perspective. 

 

 

 

Retired
Posts: 140
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Can't receive Location updates if screen is off !!!

BB10 does allow you to use Android Services.  It may be terminated when your app window is closed, but you can still use them (and certainly should use them) Smiley Happy

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

Re: Can't receive Location updates if screen is off !!!

[ Edited ]

If LocationManager is essentially shutdown when user clicks the power button, then does it matter if I can use a service? 

 

The key here I think is that BB10 is shutting down Android's LocationManager when the power button is clicked. So doing anything via a service or anything that executes in the background will just get old data or none at all by using LocationManager (right?) and LocationManager will not send any updates to anything that requested location updates while screen is off.

 

So sorry, I don't want to side track the thread here. Let's keep it on receiving GPS updates (in any way) while screen is off. Is that possible (aside from the wake lock approach)?