cordova -v): 8.1.2cordova platform ls): Android and iOS
So.. if your App is startet, and these plugin is loaded (and configurated) - just minimize the app, and run the device out of memory (with a lot of apps, or with the Fill RAM memory app) within 60 secounds after minimize, and the plugin starts a LocationService automatic - u cant stop it!
If u wait longer thant 60 seconds the background service will stop by os or plugin and don't start automatic.
I think the problem is, that if u call stop() - the attempt the serice to kill, but dont do it immediately. It will be killed after 60 seconds.
The central issue is, that u cant do anything. The device track the location all time, untill u kill the app in taskmanager.
LocationService should stop immediately after calling stop().
The LocationService runs 60 secs longer. If the app got killed caus device is out of memory, the LocationService start and dont stop to track.
Kill Service immediately
I cant use these plugin, caus no one wants a app whos tracking u all time.
I tried tausends of configurations, tried to do something on "resume ore pause" events on Corodva, but the dont trigger on out of memory.
I tried to call stop() at every event from the Plugin, but it dont stops after automatic restart..
This is what happend after killed within 60 secs:
I/com.marianhello.bgloc.service.LocationServiceImpl: Creating LocationServiceImpl
I/com.marianhello.bgloc.PostLocationTask: Creating PostLocationTask
W/com.marianhello.bgloc.service.LocationServiceImpl: Attempt to start unconfigured service. Will use stored or default.
I/com.marianhello.bgloc.service.LocationServiceImpl: Network condition changed has connectivity: true
D/com.marianhello.bgloc.service.LocationServiceImpl: Will start service with: Config[distanceFilter=3 stationaryRadius=3.0 desiredAccuracy=0 interval=10000 fastestInterval=120000 activitiesInterval=10000 isDebugging=false stopOnTerminate=true stopOnStillActivity=true startOnBoot=false startForeground=true notificationsEnabled=false locationProvider=0 nTitle=Background tracking nText=ENABLED nIconLarge= nIconSmall= nIconColor= url=https://[HIDE] syncUrl= syncThreshold=100 httpHeaders={} maxLocations=10000 postTemplate={"acc":"@accuracy","alt":"@altitude","lon":"@longitude","lat":"@latitude","speed":"@speed"}]
I/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Creating DistanceFilterLocationProvider
I/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Start recording
Than i goes the normal tracking way..
Hopy anyone has an idea. But i love these plugin!
I found a dirty solution, but worked for me:
In LocationServiceImpl.java
at
public synchronized void start() {
if (mConfig == null) {
logger.warn("Attempt to start unconfigured service. Will use stored or default.");
mConfig = getConfig();
// DONT START AGAIN IF NO URL IN CONFIG(!!!!)
if(mConfig.getUrl().equals(""))
return;
// TODO: throw JSONException if config cannot be obtained from db
}
}
put this little if to check if there is a url in config, if not, just don't create or restart the service.
My idea was a config-data if the service should restart after device is out of memory.
Or configurable if the plugin should start the service with START_STICKY or START_NOT_STICKY.
(but i don't it works well)
paD
I suggest you to not call configure, if you do not plan to start service afterwards. It should solve your problem. In others words, configure should be called only when you plan to start the service.
Hey, thanks for reply. But the problem is, if u configurate once - stop tracking. U got the same problem. If u minimized the app the Service start again.
May its possible to delete the configuration?
Not sure what configurate once - stop tracking means. Do you mean
without calling start?
?
Oh, no sorry (my english is not the best ;) )
Then the service will restart and tracking begins.
Oh well. In that case it should not start. Are you sure, you're not calling configure after you call stop?
Yh, iam sure.
If you call stop() - the service killed after 60 seconds.
After this 60 seconds, no service start again.
I have tried the excample from your project on:
Android Emulator 5.0.0 - 9.0.0
Sony with Android 8.0.0
Samsung with Android 8.0.0
and a Samsung S3 with Android 5.0.0
It happens on all of them
I found a dirty solution, but worked for me:
In LocationServiceImpl.java
atpublic synchronized void start() {
if (mConfig == null) {
logger.warn("Attempt to start unconfigured service. Will use stored or default.");
mConfig = getConfig();
// DONT START AGAIN IF NO URL IN CONFIG(!!!!)
if(mConfig.getUrl().equals(""))
return;
// TODO: throw JSONException if config cannot be obtained from db
}
}put this little if to check if there is a url in config, if not, just don't create or restart the service.
My idea was a config-data if the service should restart after device is out of memory.Or configurable if the plugin should start the service with START_STICKY or START_NOT_STICKY.
(but i don't it works well)paD
Why test the url?
Can not we create a new key, maybe DontRestart, and test this variable?
In this case, we will do:
What do you think ?
It was my idea, but it don't work.
I think u have to edit the Config-Class.
@mauron85 all our hopes rest on you! : D
I have a question maybe relating to this bug and closed bug #552:
Say we do:
Will geolocation start automatically after boot, or does BackgroundGeolocation.stop() override startOnBoot? I want to use startOnBoot because I want gelocation to start automatically when the phone reboots but only if it was active at the time of the reboot.
Im having the same problem... Can I use a lower version to avoid this issue? I need to go out at production :(
Hey dedd,
I use my solution in production. Seems to work well :)
Should be fixed in v3.0.0.