Search code examples
androidandroid-activityandroid-manifestandroid-navigation

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


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" 

Solution

  • 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.

    For more information, see the up-navigation docs. (Archived from the original, which now redirects to the Jetpack Navigation docs on designing navigation graphs)