androidandroid-lifecycle

How to know when my app has been killed?


I need to know when the user kills my app (Force stop). I've been reading the android lifecycle, which has the onStop() and onDestroy() functions, these are related to each activity the user ends on my app, but not when the user forces stop or kills my app.

Is there any way to know when the user kills the app?


Solution

  • there's no way to determine when a process is killed. From How to detect if android app is force stopped or uninstalled?

    When a user or the system force stops your application, the entire process is simply killed. There is no callback made to inform you that this has happened.

    When the user uninstalls the app, at first the process is killed, then your apk file and data directory are deleted, along with the records in Package Manager that tell other apps which intent filters you've registered for.