Merging Android manifest: removing LAUNCHER intent filter does not take effect
In my android app I am using a library project and I am using one of its activities. However, in a library project, this action has a BASIC action and an intent filter "START". So I added this activity to my manifest and removed the intent filter. Obviously, the manifests are correctly bundled into assembly / intermediate / manifests / full / debug / AndroidManifest.xml, and the activity looks as expected (no intent filter):
<activity
android:name="com.michaelrnovak.util.logger.Logger"
android:configChanges="orientation"
android:label="@string/show_log" >
</activity>
However, when I run the app from AndroidStudio in the emulator, the Library Logger activity is started instead of my AlertsActivity. What am I doing wrong?
This is the library manifest:
<?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>
and my application manifest has the following corresponding activity definitions:
<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>
source to share
Have you tried the tools: node = "remove" in the node category only? In my experience, it works.
Something like that:
<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>
source to share
I have tried many ways in a similar situation like you. I figured out what I have to add tools:node="replace"
to Activity
node to remove intent-filter
specific action
and category
. Try this :)
<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>
source to share