Search code examples
c#xamarinxamarin.android

Activity lifecycle when Clear All Apps


I would like to know, where is the documentation regarding the behavior of an Activity when the user press the Clear All button on the Recent Apps.

I would expect that some event is triggered, since I do a backup of the ongoing work on the OnDestroy() event, but it doesn't seem to be fired. (Neither I can trace it on the Output Window of VS).

Could you please provide some guidance?


Solution

  • When the user press the Clear All button on the Recent Apps, the processes of these apps will be killed by the system to free up memory.

    You can read the official document about the activity lifecycle and the process:

    https://developer.android.com/reference/android/app/Activity#activity-lifecycle

    https://developer.android.com/guide/components/activities/activity-lifecycle

    In addition, you can use the onSaveInstanceState() method to do a backup for the activity instead of in the OnDestory(). If you need more information, please read the official document.

    https://developer.android.com/guide/components/activities/activity-lifecycle#saras