Replace manifest intent-filter for extended class in flavor

galaxigirl :

In my app, flavor Lite has it's own manifest and overrides the main's SplashActivity with SplashActivityLite. The main manifest has a launcher intent-filter for SplashActivity. But since the SplashActivityLite also has a launcher intent-filter, 2 app icons are installed.

I have tried adding tools:node="replace" and tools:node="merge" to activity tag SplashActivityLite. I have tried adding tools:node="replace" to each attribute in the intent-filter (action and category tags).

How can override the intent filter of the main manifest when the class names are not the same?

CommonsWare :

Given your comment, what you seem to be aiming for is a merged manifest for this flavor where SplashActivityLite exists but SplashActivity does not.

In the flavor's manifest, I think you would need to have two <activity> elements (at least, in terms of relevance to this problem):

  • One would point to SplashActivityLite and be normal, with your MAIN/LAUNCHER <intent-filter>

  • The other would point to SplashActivity and have tools:node="remove" to get rid of it from the merged manifest

Alternatively, you could:

  • Have the SplashActivityLite normal manifest entry in the flavor

  • In main, have android:enabled="@bool/useMainSplash" on SplashActivity

  • In main, define useMainSplash to be true

  • In the flavor, define useMainSplash to be false

That would keep the manifest entry for SplashActivity but disable it so it would not be launchable.

In either approach, the SplashActivity class should be unaffected, so SplashActivityLite can extend it without issue.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=175189&siteId=1