Is there a way to reduce a dynamic links list on the same intent-filter on Android Manifest

Issue

So I’m using dynamic links in my app and I have made that one activity handles several dynamic links, but the list is getting long and literally is just the last parameter that changes, which are numbers. So is there a way to reduce the list or I will have to just keep on adding more?

<activity
        android:name="com.example.app.main.HNSPS1"
        android:exported="true">

        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <!--Drinks-CoffeeShops-->
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/1/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/2/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/3/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/4/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/5/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/6/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/7/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/8/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/9/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/10/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/11/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/12/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/13/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/14/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/15/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/16/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/17/" />
            <data android:host="myapp.page.link" android:scheme="https" android:path="/DrinksCoffeeShops/18/" />
             ...
</intent-filter>
    </activity>

This is my android manifest and as you can see is just the last parameter "/1/" that changes for all the links. I’m planning on adding till like 50.

Solution

I finally figure it out and I will post what I did If someone is having the same question as me.
So since all the dynamic links have the same path just different numbers at the end, what I did was use android:pathPrefix instead of android:path and that way all the incoming links with the prefix /DrinksCoffeeShops/ will open the same activity regarless of the suffix, in this case the numbers at the end /#/
At the end my manifest look this way:

<activity
    android:name="com.example.app.main.HNSPS1"
    android:exported="true">

    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <!--Drinks-CoffeeShops-->
        <data android:host="myapp.page.link" android:scheme="https" android:pathPrefix="/DrinksCoffeeShops/" />
         ...
</intent-filter>
    </activity>

As you guys can see my manifest is much smaller and using more dynamic links is more convinient. Hope this helps.

Answered By – Qwip Business

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published