I have noticed this dual behavior of app crash in different applications. Sometimes on crashing it simply exits the app but other times it lands on some previous activity. Is this a known behavior or is there any logic behind this which can be handled. Tried to search it on SO but couldn't find right combination of keywords for my problem. Thanks
Asked
Active
Viewed 428 times
0
-
maybe the logcat output could be helpfull – Opiatefuchs Jan 28 '15 at 08:40
-
It would be helpful to leave a comment while down voting. – Vikram Singh Jan 28 '15 at 08:42
-
I think You get downvoted because it´s a too vague question without any code examples or stacktrace. It´s unclear what You mean by "lands on previous activity". If You have no code to share, tell us exactly at which point this happen. For example, start app-->do some stuff-->app crash because...-->etc... – Opiatefuchs Jan 28 '15 at 08:49
-
ohh..I tried to ask it as a generic question which is not related to specific application or code because I have seen this in multiple application. – Vikram Singh Jan 28 '15 at 08:57
-
Post your stacktrace. – Piyush Jan 28 '15 at 09:00
-
ah, ok. I think the most important thing is to prevent any crash. I have not seen a behaviour like this. What I think is, If You start Activity A, make a button click and get forwarded to Activity B, Activity A is in the background and not finished. If then Activity B gets crashed, Activity A still exists. – Opiatefuchs Jan 28 '15 at 11:11
-
Try to clear the backstacks: http://stackoverflow.com/a/27795433/3922207 – Anggrayudi H Jan 28 '15 at 12:39
1 Answers
2
It depends on the FLAGS you created the Intent with. For example, with CLEAR_TOP If the activity being started is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it are destroyed and this intent is delivered to the resumed instance of the activity (now on top), through onNewIntent()).
When an Activity crashes if there are no more back-stacked activities of the same app, it will simply exit and show the device's home.

Shine
- 3,788
- 1
- 36
- 59