Are both XML attributes for newer and older APIs needed?

49 views Asked by At

Should I specify both XML attributes for newer and older APIs in my AndroidManifest file if the minSdk is set to API 11? If not, which one should I specify?

Here is an example of using both parentActivityName attributes:

<activity
      android:name=".SettingsActivity"
      android:label="@string/action_settings"
      android:parentActivityName=".MainActivity">
      <meta-data
             android:name="android.support.PARENT_ACTIVITY"
             android:value=".MainActivity"/>
</activity>
1

There are 1 answers

0
Amin Tavassolian On BEST ANSWER

Based on the documentation:

The android:parentActivityName attribute declares the name of this activity's parent activity within the app's logical hierarchy. The system uses this value to implement default navigation behaviors, such as Up navigation on Android 4.1 (API level 16) and higher. You can provide the same navigation behaviors for older versions of Android by using the Support Library and adding the element as shown here.

So it means yes! You need to indicate both attributes if your minimum API requires.

Cheers A.