Android清单合并:删除启动器意图过滤器不会';不生效
在我的android应用程序中,我使用一个库项目,我使用它的一个活动。但是在库项目中,该活动具有主操作和启动器类别意图过滤器。因此,我将该活动添加到清单中,并删除了意图过滤器。清单似乎正确地合并到build/intermediates/manifests/full/debug/AndroidManifest.xml中,并且活动看起来与预期的一样(没有意图过滤器):Android清单合并:删除启动器意图过滤器不会';不生效,android,merge,android-manifest,intentfilter,android-launcher,Android,Merge,Android Manifest,Intentfilter,Android Launcher,在我的android应用程序中,我使用一个库项目,我使用它的一个活动。但是在库项目中,该活动具有主操作和启动器类别意图过滤器。因此,我将该活动添加到清单中,并删除了意图过滤器。清单似乎正确地合并到build/intermediates/manifests/full/debug/AndroidManifest.xml中,并且活动看起来与预期的一样(没有意图过滤器): 但是,当我在emulator中从AndroidStudio启动应用程序时,将启动库的记录器活动,而不是AlertsActivit
但是,当我在emulator中从AndroidStudio启动应用程序时,将启动库的记录器活动,而不是AlertsActivity。我做错了什么
这是库的清单:
<?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>
我的应用程序清单具有以下相关活动定义:
<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>
像你一样,我在类似的情况下尝试了很多方法。我发现我必须在
活动
节点中添加工具:node=“replace”
,以删除意图过滤器
的特定操作
和类别
。试试这个:)
仅删除
对我不起作用,但同时删除和
会起作用<代码>
这比我以前做的有所改进。非常感谢@Commonware,您最好发布一个答案,以便其他人更容易看到此解决方案可能重复@Gavriel,请检查我的答案。这可能会解决你的问题。嘿,我有点怀疑。您刚刚使用了节点“replace”,但还添加了意图过滤器,而没有“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>
<activity
android:name="com.michaelrnovak.util.logger.Logger"
android:label="@string/show_log"
android:configChanges="orientation"
tools:replace="android:label"
tools:node="replace">
<!-- Rewrite the intent-filter you want -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>