Android killing background location app after awhile

21 views
Skip to first unread message

James

unread,
Nov 27, 2019, 12:03:23 PM11/27/19
to CodenameOne Discussions
Device: OnePlus running android 10

I am experiencing issues with prolonged background app tracking on Android 10. It seems that after a period of time, the app is killed entirely and the background locations stop coming in.

In build hints, I have android.xpermissions set to:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

I am starting location tracking like so:

CommonUtil.log("Starting Tracking"); LocationManager.getLocationManager().setLocationListener(new LocationListenerImpl(), new LocationRequest(LocationRequest.PRIORITY_MEDIUM_ACCUARCY, 1000 * 60 * 5)); LocationManager.getLocationManager().setBackgroundLocationListener(LocationListenerImpl.class);

I am also starting geofencing like so:

LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, revisedGeofences.get(id));

Upon entering a geofence, I simply increase tracking accuracy

LocationManager.getLocationManager().setLocationListener(new LocationListenerImpl(), new LocationRequest(LocationRequest.PRIORITY_HIGH_ACCUARCY, 1000 * 60 * 2));

All of this works fine for the first several hours, and then it suddenly stops until the app is manually opened. Any thoughts?

Steve Hannah

unread,
Nov 27, 2019, 2:08:28 PM11/27/19
to codenameone...@googlegroups.com
These can be a little tricky to debug.  Especially if it takes a few hours to occur.  Can you access the DDMS log from your device?  It will probably offer some clues as to what it going on there.

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/99b32a00-d82d-403a-bb17-60edd8e8f61f%40googlegroups.com.


--
Steve Hannah
Software Developer
Codename One
Reply all
Reply to author
Forward
0 new messages