How will android activity be restored after its process?

As stated in the Dev Guide, actions can be restored after "the application process is killed" and "The user goes to Activity." First of all, I have never seen this happen. It seems that I cannot "go back" to the Activity, when its process is killed, the Activity simply left the stack after the process disappeared.

If this happens, how will this happen?

And I saw a strange but good thing: There is one Activity A1 that launches Activity A2 another application. Now A2 is the main task. When memory gets low, at least on emulators (where I can easily eat RAM), A2 will be killed instead of A1 .

I'm afraid, for example, something like this: My application has two activities on the stack, and we call them A0 and A1 . And A1 again launched Activity A2 another application. When A0 was about to start A1 , it gives A1 reference to the data object D Now, if the process for A0 and A1 killed and A2 is in the foreground, D is also lost. When A2 finishes, it seems that you need to restore at least A1 . And so A1 will have to handle recovery D And what else will A1 have to find a way to tell the still dead A0 link to the restored D Is it difficult or was I wrong?

+4
source share
1 answer

The system will do everything possible to keep the priority application active.

Intent that was used to trigger the activity is saved by the system when the process is about to be killed.

Thus, as soon as the user returns to the application that was killed, the application will be restored, and the same Intent will be launched to start this operation, including all the additional functions that it may have.

This means that any data that you pass to Intent to trigger an activity will still exist when activity is restored.

You may not notice this, but Android really kills and recreates the process in everyday use, and all this means that the platform supports multitasking.

In the "Development" settings, you should always test your application with the option "Do not perform actions".

+7
source

Source: https://habr.com/ru/post/1415811/


All Articles