开发者

death of an activity re-launches the process

开发者 https://www.devze.com 2023-01-29 10:44 出处:网络
I have a set of activities starting from my home screen through a few list activities to my final screen.

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 o开发者_如何学Cne 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 ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消