新旧 API 都需要 XML 属性吗?

Are both XML attributes for newer and older APIs needed?

如果 minSdk 设置为 API 11,我是否应该在我的 AndroidManifest 文件中为较新和较旧的 API 指定 XML 属性?如果不是,我应该指定哪一个?

下面是使用两个 parentActivityName 属性的示例:

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

基于文档:

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.

所以这意味着是的!如果您的最低 API 需要,您需要指明这两个属性。

干杯 A.