ActionBar 'up' button destroys parent activity, 'back' does not ActionBar 'up' button destroys parent activity, 'back' does not android android

ActionBar 'up' button destroys parent activity, 'back' does not


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?


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.


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.