java - PreferenceActivity 子类不应在 list 中导出 (ExportedPreferenceActivity)

标签 java android android-fragments android-manifest

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 是一个具有两个 PreferenceFragmentsAppCompatPreferenceActivity,并在 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/

相关文章:

android - 如何将可变数量的参数传递给数据绑定(bind)适配器?

Android - 如何在替换为另一个 fragment 之前保存 fragment 状态?

java - 如何修复 Android 中 fragment 中未找到 View 的问题

Java配置文件问题

java - 如何用递归简化算术表达式树?

java swing JTabbedPane 位置选项卡标题从右下到左

带有抽屉 + 工具栏 + fragment 的 Android App 模板

Windows 通信的 Java 接口(interface)? (OLE、OPC、DDE)

java - Android中Togglebutton结合Intent显示Image

android - 如何将android项目添加到git