When my application crashes in any activity, it seems like it tries to reopen the last activity from the backstack. However the last activity can't launch properly for some reason and crashes again. Sometimes it happens several times. Seems like it starts flowing back in the backstack and crashes all the activities there. So all I can see is a flashing "Unfortunately your application has stopped" message multiple times before I get back to the Home screen.
I'm always overriding the onBackPressed() function, so anytime I'm navigating between activities I call this:
startActivity(new Intent(this, NextActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
I'm using hockey app to catch stack trace, but because of this issue I cant catch the first crash where the issue occurred.
Has anyone seen such an issue?
UPDATE:
Turns out Android kills the process when the application crashes... It means I lost my static variables when the Activity on the top crashed so Activities backwards couldn't restore their state.