Navigation and saved instance data

The application has 2 actions, A and B.

A has instance data stored

@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("foo", 0); } 

and A has

 int bar; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ... if (savedInstanceState != null) { bar = savedInstanceState.getInt("foo"); } else { bar = -1; } } 

for data recovery.

In action B, the action bar and

 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); // ... } 

to enable navigation. A is also indicated as the parent activity of B in AndroidManifest.xml .

When a user moves from A to B onSaveInstanceState , and if they return to A using the active back button, A correctly restores the saved information.

However, when the user navigates from A to B onSaveInstanceState , and then the navigation is used up to return to onCreate(Bundle savedInstanceState) , null is transmitted, even though the information has been saved.

How do I navigate to pass the package created on onSaveInstanceState ?

+8
android android-activity android-actionbar
source share

No one has answered this question yet.

See similar questions:

62
Return from action using navigateUpFromSameTask ()
2
savedInstanceState in parent activity is null when you press the up button in child activity
one
Restore activity status after clicking the back button

or similar:

2510
How to keep Android activity state by saving instance state?
1270
How to transfer data between actions in an Android application?
6
how to set up CameraView for Android ZBar QrCode Reader
2
Can someone show me a simple working implementation of PagerSlidingTabStrip?
2
savedInstanceState is always null after killing activity
0
Android simple login screen crash when logging, no errors in eclipse. What kind of java class activity is to blame?
0
Android - restore activity using onSaveInstanceState null
0
Is an Activity instance really destroyed after calling the onDestroy () method?
0
Android navigation thread issue
0
Why should I override onSavedInstanceState to retrieve instance state in android?

All Articles