Question

I have a set of activities starting from my home screen through a few list activities to my final screen. When i have an exception for whatever reason i get the "Sorry....yada yada yada, must be closed" dialog and the activity along with the process get shut down, i would expect it to stay that way however the process itself get's relaunched with the same activity stack up to the activity before the one that crashed. It's a very useful feature however since i don't have Bundle savings yet to save my data in onDestroy one activity crash and relaunch will cause an avalanche... Is there a way to disable that feature ? change the launch mode should help here ?

Was it helpful?

Solution

When an app is crashed, all static variables are cleaned. You can write a base activity class to always check (in onCreate) if the state of the app is valid (static not null). If not valid (null), restart the app by launching the first activity with the flag FLAG_ACTIVITY_CLEAR_TOP.

See similar suggestion in the first point in this answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top