Android Studio 抛出棉绒警告说
PreferenceActivity subclass com.myapp.app.SettingsActivity should not be
exported in the manifest
Inspection info:Fragment injection gives anyone who can send your
PreferenceActivity an intent the ability to load any fragment, with any
arguments, in your process. Issue id: ExportedPreferenceActivity
我从来没有真正注意到这个警告何时开始出现,但我找不到在不破坏活动的情况下修复它的方法。设置活动是一个具有两个PreferenceFragments
的AppCompatPreferenceActivity
,在初始屏幕之后创建。我已经尝试在我的清单中设置android:exported="false"
.xml但它给出了一个错误,因为操作。VIEW 无法关闭导出。
相关清单.xml代码:
<activity
android:name=".SettingsActivity"
android:label="@string/app_name"
android:theme="@style/SplashScreen">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
不要
用启动器暴露它(这听起来像它抱怨的内容):
<category android:name="android.intent.category.LAUNCHER"/>
如果可能,请删除:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
如果您无法全部删除,请删除此行:
<action android:name="android.intent.action.VIEW" />