My application runs on a special device that is running a custom build Android Gingerbread 2.3.7
There are conditions under which the system will stop my application. I assume that the device manufacturer is considering these emergencies when all third-party applications should be immediately turned off, the device can carry out its core tasks.
I can duplicate the behavior that I see on the device using the emulator, and the DDMS, choosing my task and pressing the "Stop Process" button. That's the behavior that I see.
My application usually performs four actions: Activity A starts activity B, B launches the Activity C, and C starts the activity of D. Thus, when the activity D works on top of my stack:
A - B - C - D
If at this point the process ends, step D does not receive onPause () call or onStop (). It is not possible to save its state.
After the process is dead, Android ActivityManager launches a new challenge for my application and runs Activity C. I think that this is a standard Android behavior to reset the broken application.
My question is: can I control this behavior is restarted? If Android starts to restart my application, I need to restore the stack activity, Activity C does not really make sense to run autonomously (pressing "Back" to exit from the application, and it does not make sense for this action).
Can I prevent the restart? Can I restart my steps in the sequence? Can I restart only the beginning of activity of A?
I found this interesting discussion , which is, I think, explains why Activity C restarts, not the activity of D.
As for the restart of activity - if the process is performing the activities of the foreground disappears, the system discards if it does not have a valid saved state (usually that means that he stopped and gave the system the result onSaveInstanceState to pause). As soon as he decided whether to drop this activity or not, it will resume the activity is now at the top of the stack. If this is one of your activities - or because you have other, crashed, or the one that crashed, was somehow established a pause state - then it will restart your process to show that the top activities.
And some of these issues, such as Prevent restoration activity of the stack? and this interesting thread