I am writing an Android app which must always be running in the background until the user exits it from the app's menu. But now I notice that in Android after some time my app is stopped by itself without user intervention.
Any idea how to make sure my app will always be running in the background?
AndroidMainfest.xml looks like this with presistent=true:
For your activity, in the manifest xml, put:
android:persistent="true"
If you need to run at all times, look into a
Service
andstartForeground
. If you can let yourService
die but get restarted, look intoonStartCommand
andSTART_STICKY
.You need to run a Service of your own. http://developer.android.com/reference/android/app/Service.html