Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Starting the App Navigation with Back and Up

How can I set parent activity in android studio?

Ecliplise has a tab for Application,where we can relate two activities,but in android studio I don´t know how can I do the same thing,anyone can help me?

1 Answer

Android Studio does not have the tabs, you have manually do it in the xml. add android:parentActivityName= parent activity here is an example

            android:screenOrientation="portrait" >
Raghda Talaa't
Raghda Talaa't
2,944 Points

But this requires a minimum API level of 16 and in the video he is working on API 14 as the minimum Is that right?

Lisa Steendam
Lisa Steendam
6,825 Points

My minSdkVersion is 15, works just fine

Raghda Talaa't
Raghda Talaa't
2,944 Points

When i add this line it gives me this error:

Attribute "parentActivityName" is only used in API level 16 and higher (current min is 14)

Raghda Talaa't
Raghda Talaa't
2,944 Points

Ok, I found it:

Beginning in Android 4.1 (API level 16), you can declare the logical parent of each activity by specifying the android:parentActivityName attribute in the <activity> element.

If your app supports Android 4.0 and lower, include the Support Library with your app and add a <meta-data> element inside the <activity>. Then specify the parent activity as the value for android.support.PARENT_ACTIVITY, matching the android:parentActivityName attribute.

Here is the link: