Issue
On Activity 1 I have EditText and Button. On clicking the button Activity 2 loads:
Intent intent = new Intent(this, Activity2.class);
startActivity(intent);
It is configured to have Activity 1 as parent:
<activity android:name=".Activity2" android:parentActivityName=".Activity1" >
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.domain.app.Activity1" />
</activity>
When I click back button on Activity 2, the text entered by user in edit field is lost. How can I restore it?
I tried onSaveInstanceState
and onRestoreInstanceState
on Activity 1 but it doesn't work (onRestoreInstanceState
is never called).
Solution
Make sure you don't confuse "back" with "up". Up navigation is not the same thing as the bottom-left or physical back button. It recreates the up Activity by default, unless you set the launch mode to "singleTop" for the up Activity in the manifest.
Answered By - BladeCoder
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.