我希望通过点击偏好设置条目来打开应用程序设置。因此,我在preferences.xml中添加了一个意图。
<PreferenceScreen
android:key="DELETE_DATA"
android:title="@string/pref_delete_data">
<intent android:action="android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS"/>
</PreferenceScreen>
我已经将Intent-filter添加到了AndroidManifest.xml文件中
<activity
android:name=".SettingsActivity"
android:label="@string/title_activity_settings"
android:parentActivityName=".MainActivity">
<intent-filter>
<action android:name="android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
...
使用上述代码后,没有任何操作或错误发生。但我不知道为什么...
如果我删除<category>
,就会出现错误,因此意图被触发。有任何想法吗?
设备:搭载Android 4.4.4的HTC One M8