I've asked a question about keeping service alive but I didn't find the solution so I have another simpler question.
android doc says if android kills a service with START_STICKY on return of onStartCommand in low memory state, it will recreate the service if I'm correct.
but this service gets killed and disappear in running tasks after a period of time but it didn't get recreated! I run this service in android 4.4.2 on my phone, when screen is on, it survived about 20 minutes but when screen is off it disappeared after about 3 or 4 minutes... on my tablet (again android 4.4.2) it stayed longer, about 4 or 5 hours and then got disappeared again (I got different results on different tests). I even test it on android 5 and the result was similar to tablet with android 4.4.2
am I missing something here? I thought service wont get destroyed when we are using return START_STICKY until I call stopService
here's my service:
public class MyService extends Service {
@Override
public void onCreate() {
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
public void onDestroy() {
super.onDestroy();
}
}
sry for bad english :)