Android: Activities Destroyed Unexpectedly, Null Savedinstancestate
Solution 1:
Although the question mentions Fragments, the problem is actually with up navigation.
The default implementation for up navigation doesn't work exactly as one would expect for standard activties. In particular, when the parent activity has launchMode="standard"
(the default), pressing the up button will create a new instance of it, not return to the previous one.
There are two alternatives for solving this problem:
- Changing the
launchMode
ofImpulseActivity
tosingleTop
in the Manifest. Overriding the home button action to launch the intent with the
FLAG_ACTIVITY_CLEAR_TOP
flag. For example, inEventActivity.onOptionsItemSelected()
:if (id == android.R.id.home) { Intent intent = NavUtils.getParentActivityIntent(this); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); NavUtils.navigateUpTo(this, intent); returntrue; }
Either of these will bring your old activity to the top of the stack.
Solution 2:
if your fragments have layout just like activity example mainlayout.xml you can use intent for open each fragment with same details and dont use onstop(); pack create intent and intent flags in the main fragment activity
Post a Comment for "Android: Activities Destroyed Unexpectedly, Null Savedinstancestate"