Android activity-alias includes

15 Views Asked by At

I added a bunch of activity-alias tags to my Android Manifest so users can change the app icon of our app. Is there a way to group intent-filters together and use an include tag or some other tag so I don't have to copy-paste all of the activity intent-filters and meta data in each alias?

Current Implementation

<activity
    android:name="com.example.MainActivity"
    android:windowSoftInputMode="adjustResize"
    android:theme="@style/Theme.Example.Splash"
    android:exported="true">

    <meta-data android:name="android.app.shortcuts"
        android:resource="@xml/shortcuts" />

    <!--<meta-data
        android:name="android.metadata.SLICE_URI"
        android:value="content://com.example.app/slice" />-->

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

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="app" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="com.example.app" />
        <data android:host="sticker" />
    </intent-filter>
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:scheme="https"
            android:host="com.example.app"
            android:pathPrefix="/app/" />
    </intent-filter>
</activity>

<activity-alias
    android:name="${main_activity_brutus_alias}"
    android:targetActivity=".MainActivity"
    android:exported="true"
    android:enabled="false"
    android:icon="@mipmap/ic_launcher_brutus"
    android:roundIcon="@mipmap/ic_launcher_brutus_round">

    <meta-data android:name="android.app.shortcuts"
        android:resource="@xml/shortcuts" />

    <!--<meta-data
        android:name="android.metadata.SLICE_URI"
        android:value="content://com.example.app/slice" />-->

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

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="app" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="com.example.app" />
        <data android:host="sticker" />
    </intent-filter>
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:scheme="https"
            android:host="com.example.app"
            android:pathPrefix="/app/" />
    </intent-filter>

</activity-alias>

What I would like to do

<activity
    android:name="com.example.MainActivity"
    android:windowSoftInputMode="adjustResize"
    android:theme="@style/Theme.Example.Splash"
    android:exported="true">

    <include name="activity_intents.xml" />
</activity>

<activity-alias
    android:name="${main_activity_brutus_alias}"
    android:targetActivity=".MainActivity"
    android:exported="true"
    android:enabled="false"
    android:icon="@mipmap/ic_launcher_brutus"
    android:roundIcon="@mipmap/ic_launcher_brutus_round">

    <include name="activity_intents.xml" />

</activity-alias>

I know this isn't the right format at all, but I was just wondering if there was a way to do something similar so my Android Manifest is not just all the same stuff over and over again.

0

There are 0 best solutions below