Search code examples
androidmanifestdeep-linking

Android deep linking showing duplicate app in create chooser


I'm using deep linking to open my app with link and I need to open 5 activities based on type of link so I defined 5 type of link in my manifest and it works fine but here is the problem; In most of devices it works fine but in some devices Android create chooser show five of my application like this and its really annoying

enter image description here

here is my code defining all 5 type of links in manifest to open different activities:

    <activity
        android:name=".ui.main.MainActivity">
        <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="https" />
            <data android:host="aionet.ir" />
            <data android:path="/" />
            <data android:pathPrefix="/search" />
        </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="aionet" />
            <data android:host="backcallback" />
            <data android:path="/" />
            <data android:pathPrefix="/index" />
        </intent-filter>
    </activity>
    <activity
        android:name=".ui.movieDetails.MovieDetailActivity">
        <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="https" />
            <data android:host="aionet.ir" />
            <data android:path="/" />
            <data android:pathPrefix="/movies" />
        </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="aionet" />
            <data android:host="backcallback" />
            <data android:path="/" />
            <data android:pathPrefix="/movie" />
        </intent-filter>
    </activity>
    <activity
        android:name=".ui.seriesDetails.SeriesDetailActivity">
        <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="https" />
            <data android:host="aionet.ir" />
            <data android:path="/" />
            <data android:pathPrefix="/series" />
        </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="aionet" />
            <data android:host="backcallback" />
            <data android:path="/" />
            <data android:pathPrefix="/serie" />
        </intent-filter>
    </activity>
    <activity
        android:name=".ui.cast.CastActivity">
        <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="https" />
            <data android:host="aionet.ir" />
            <data android:path="/" />
            <data android:pathPrefix="/cast" />
        </intent-filter>
    </activity>
    <activity
        android:name=".ui.buyPackage.BuyPackageActivity">
        <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="https" />
            <data android:host="aionet.ir" />
            <data android:path="/" />
            <data android:pathPrefix="/packages" />
            <data android:pathPrefix="/order" />
        </intent-filter>
    </activity>

Solution

  • You don't want to use path and pathprefix like that. One or the other. Right now, all of those activities think they match based on the path. Use pathPrefix alone.