Must I specify the parent activity name in the Android Manifest?

Kaloyan Roussev picture Kaloyan Roussev · Oct 6, 2013 · Viewed 34.8k times · Source

I have an activity that starts another activity.
Is it mandatory that I specify the parent activity in the Android Manifest? Im asking this because there might be other activities that will start this one as well, so should I specify all of them?

android:parentActivityName="com.example.myfirstapp.MainActivity" 

Answer

Szymon picture Szymon · Oct 6, 2013

As per docs -> section android:parentActivityName:

The system reads this attribute to determine which activity should be started when the user presses the Up button in the action bar. The system can also use this information to synthesize a back stack of activities with TaskStackBuilder.

So you only need to specify that if you're going to use up-navigation (as opposed to navigation by back button) or TaskStackBuilder. In other cases, you don't need it.

Check in here about up-navigation: http://developer.android.com/design/patterns/navigation.html