Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep an Android app running indefinitely?

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?

like image 606
perumal316 Avatar asked Aug 20 '10 09:08

perumal316


2 Answers

You need to run a Service of your own. http://developer.android.com/reference/android/app/Service.html

like image 59
Konstantin Burov Avatar answered Oct 23 '22 17:10

Konstantin Burov


If you need to run at all times, look into a Service and startForeground. If you can let your Service die but get restarted, look into onStartCommand and START_STICKY.

like image 37
jakebasile Avatar answered Oct 23 '22 17:10

jakebasile