Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace launching activity with flavors

Is it possible to replace the activity that gets the intent-filter

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

by configuring flavors?

like image 843
FeleMed Avatar asked Jul 22 '15 14:07

FeleMed


1 Answers

There are a number of ways to accomplish this thanks to the manifest merger.

The easiest way is to use a placeholder in your manifest and define the appropriate class in your build.gradle.

For example, in your manifest:

<activity android:name="${launchActivityName}">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>

And in your build.gradle:

productFlavors {
    flavor1 {
        manifestPlaceholders = [ launchActivityName:"com.example.MainActivity"]
    }
}

You can also include a different manifest file with each flavor.

like image 59
Bryan Herbst Avatar answered Oct 27 '22 20:10

Bryan Herbst