0

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();
}
monok
  • 494
  • 5
  • 16
  • Possible duplicate of [this](https://stackoverflow.com/questions/7236782/is-an-android-service-guaranteed-to-call-ondestroy) and [this](https://stackoverflow.com/questions/13904434/android-service-ondestroy-method-not-called-when-using-force-stop/42344773) – Fabio May 06 '20 at 07:59
  • Unfortunately, yes. Thanks for the pointers. – monok May 07 '20 at 06:34

0 Answers0