I have a relatively simple Android app with one Activity
showing a list of items and another showing details of a selected item. I start the list activity, whi
In the android manifest.xml adding the following attribute for the parent activity tag worked for me.
android:launchMode="singleTop"
Reference : http://developer.android.com/guide/topics/manifest/activity-element.html
Refer the similar question: How can I return to a parent activity correctly?
It looks like your parent activity isn't setup properly in your manifest. Add this inside your ShowInstanceActivity activity tag:
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".agenda.ListInstancesActivity" />
So, your final activity tag should look like:
<activity
android:name=".agenda.ShowInstanceActivity"
android:label="@string/show_instance_activity_title"
android:parentActivityName=".agenda.ListInstancesActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".agenda.ListInstancesActivity" />
</activity>
when you specify parent activity in manifest then it gets restarted when you click on up Navigation button in action bar.
check this i already answered this question
https://stackoverflow.com/a/32401235/3479012
you need to override up nevigation button in actionbar by accessing it by android.R.id.home in onOptionsItemSelected and do finish top activity.
You can override what the actionbar up button should do like:
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
And recreate the back button effect.