-
Notifications
You must be signed in to change notification settings - Fork 0
Android implementation
Q: Wouldn't Android still kill the main cordova activity regardless of keeprunning property or android:persistent tag? Then any javascript callbacks wouldn't execute.
A: According to http://stackoverflow.com/questions/21001439/keeprunning-phonegap-cordova
// Keep app running when pause is received. (default = true)
// If true, then the JavaScript and native code continue to run in the background
// when another application (activity) is started.
protected boolean keepRunning = true;
So basically keepRunning should keep updating your main cordova activity with position updates (using javascript callbacks).
Another thing. LocationUpdateService is (android.app.Service).
From the docs:
- A Service is not a separate process. The Service object itself does not imply it is running in its own process; unless otherwise specified, it runs in the same process as the application it is part of.
- A Service is not a thread. It is not a means itself to do work off of the main thread (to avoid Application Not Responding errors).
Thus a Service itself is actually very simple, providing two main features:
A facility for the application to tell the system about something it wants to be doing in the background (even when the user is not directly interacting with the application). This corresponds to calls to Context.startService(), which ask the system to schedule work for the service, to be run until the service or someone else explicitly stop it.
Another interesting fact from [Context.startService()] (http://developer.android.com/reference/android/content/Context.html#startService(android.content.Intent)) (also Cordova Context???)
The system attempts to keep running services around as much as possible. The only time they should be stopped is if the current foreground application is using so many resources that the service needs to be killed. If any errors happen in the service's process, it will automatically be restarted.
According to all this info, it looks like your app is consuming too many resources and was killed by system. If your app is not resource intensive, it should be OK to use this plugin.
There is safeguard implemented, when configuration option stopOnTerminate
is false. In this case when main activity is killed by the system, plugin (background service) will start persisting locations into sqlitedb. Persisted locations can be retrieved later by backgroundGeoLocation.getLocations
method. But keep in my mind that background service may be also killed.
PS: If you've different conclusion, please keep me informed, so we can improve the plugin, if possible.