Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Intent for each app flavor?

Say I have app A and B. App B has multiple build flavors but each one is slightly different and I want to launch a specific flavor from app A.

I have considered using one custom shared intent but I don't want the OS to prompt the user about which version to use to handle the intent if they have multiple versions of B installed.

Is it possible to programatically define unique custom intents for each flavor of an application?

like image 429
kira_codes Avatar asked Oct 20 '25 18:10

kira_codes


1 Answers

In order to use one shared AndroidManifest between multiple flavors and have unique intents for each I added a manifest placeholder for each flavor in build.gradle

default {
    manifestPlaceholders = [uriPrefix: "myprefix"]
}
someFlavor{
    manifestPlaceholders = [uriPrefix: "otherprefix"]
}

In AndroidManfest.xml use a manifest placeholder like so in the intent filter:

        <intent-filter>
            <action android:name="com.custom.app.${uriPrefix}.SOME_ACTION" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="${uriPrefix}" />
        </intent-filter>
like image 156
kira_codes Avatar answered Oct 23 '25 07:10

kira_codes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!