Android list 合并 : removing LAUNCHER intent-filter doesn't take effect

标签 android merge android-manifest intentfilter android-launcher

在我的 android 应用程序中,我使用了一个库项目,并且我使用了其中的一个 Activity 。但是在图书馆项目中,该 Activity 具有 MAIN 操作和 LAUNCHER 类别 intent-filter。所以我将该 Activity 添加到我的 list 中并删除了 intent-filter。 list 似乎已正确合并到 build/intermediates/manifests/full/debug/AndroidManifest.xml 中,并且 Activity 看起来符合预期(没有 intent-filter):

    <activity
        android:name="com.michaelrnovak.util.logger.Logger"
        android:configChanges="orientation"
        android:label="@string/show_log" >
    </activity>

但是,当我在模拟器中从 AndroidStudio 启动应用程序时,将启动库的 Logger Activity ,而不是我的 AlertsActivity。我做错了什么?

这是库的 list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.michaelrnovak.util.logger"
      android:versionCode="8"
      android:versionName="1.5">
    <uses-permission android:name="android.permission.READ_LOGS" />
    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity android:name=".Logger"
                  android:label="@string/app_name"
                  android:configChanges="orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="7" />
</manifest> 

我的应用程序 list 具有以下相关 Activity 定义:

    <activity
        android:name=".AlertsActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:launchMode="singleTop" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />          </intent-filter>
    </activity>
    <activity android:name="com.michaelrnovak.util.logger.Logger"
        android:label="@string/show_log"
        android:configChanges="orientation"
        tools:replace="android:label"
        >
        <intent-filter tools:node="removeAll" />
    </activity>

最佳答案

您是否仅在类别节点上尝试过 tools:node="remove"?根据我的经验,它似乎有效。

像这样:

<activity android:name="com.michaelrnovak.util.logger.Logger"
        android:label="@string/show_log"
        android:configChanges="orientation"
        tools:replace="android:label"
        >
        <intent-filter>
            <category   tools:node="remove" android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

关于Android list 合并 : removing LAUNCHER intent-filter doesn't take effect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31262389/

相关文章:

使用基于短信的身份验证的 iPhone 或 Android 应用程序?

java - 如果不先滚动,则不会显示 RecyclerView 项目中的图像

c++ - 在 C++ 中通过引用传递未知大小的数组

version-control - 合并 IntelliJ IDEA .IPR 和 .IWS 文件

android - 将文件复制到 Android 设备内部区域需要 list 权限吗?

android - 不能使用 list 占位符来删除权限

java - 如何在android中正确设置位图的像素?

java - GCM 推送通知实现

python - Pandas Dataframe 合并其中 1 列匹配,但另一列的值不存在

android - RequestPermissions 不显示对话框