onDestroy() not called

47 Views Asked by At

I have a service that I start via and return START_REDELIVER_INTENT

public int onStartCommand(Intent intent, int flags, int startId) {
     ...
     return START_REDELIVER_INTENT;
}

so it gets restarted after being killed by Android after a day or so.

But my onDestroy does not seem to get called because I don't see the file updated, while I see timestamps from by debug write to another file within onCreate and onStartCommand methods. What am I missing here?

@Override
public void onDestroy() {
    String nowDateAndTime = sdf.format(new Date());
    writeToFile(nowDateAndTime,"calm-destroyed.txt");
    super.onDestroy();
}
0

There are 0 best solutions below