Android Studio 抛出一条 lint 警告
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
我从未真正注意到此警告何时开始出现,但我找不到在不中断 Activity 的情况下修复它的方法。 SettingsActivity 是一个具有两个 PreferenceFragments
的 AppCompatPreferenceActivity
,并在 SplashScreen 之后创建。我已经尝试在我的 Manifest.xml 中设置 android:exported="false"
,但它给出了一个错误,因为 action.VIEW 不能关闭导出。
相关Manifest.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"/>
关于java - PreferenceActivity 子类不应在 list 中导出 (ExportedPreferenceActivity),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54044007/