0

My android app is based on Cordova and fetches an xml file at a specified, continuously. It must do so. But it's lage ~ 70MB in ram and sometimes it gets killed.

Is there a way to create a foreground service bound to the process so that while the service is in foreground, the process won't get killed?

2 Answers 2

0

Check startForeground() method in Service class. You can also acquire wake lock on running service. It will ensure that device is still awake during processing your job. Don't forget to "unlock" it after you finish reading xml. http://developer.android.com/reference/android/os/PowerManager.WakeLock.html.

WakefulBroadcastReceiver is great helper to start service with this wake lock. Check here http://developer.android.com/reference/android/support/v4/content/WakefulBroadcastReceiver.html

0

What is the minSdk version of your application? Maybe you can implement the onTaskRemoved() method to restart your service when is destroyed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.