Search code examples
javaandroiddeep-linkingandroid-deep-link

How to fix not show application icon into app drawer?


In my application i want use deeplink. when added intent-filter for deeplink in launcher activity, gone application icon into app drawer!
But when remove deeplink intent-filter show application icon into app drawer.

Manifest codes :

<activity android:name=".Pages.Splash.SplashPage">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
        <!-- DeepLink -->
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="www.example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />
        <data
            android:host="example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />

    </intent-filter>
</activity>

when use above codes, not show application icon in app drawer, but when remove below codes from manifest show icon.

        <!-- DeepLink -->
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="www.example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />
        <data
            android:host="example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />

i want when open users click on link, first start launcher activity, then dynamically open another activity.

How can i fix it?


Solution

  • You should create two separate intent-filters. Try below code in your <activity/> tag:

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    
        <!-- DeepLink -->
        <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:host="www.example.com"
                android:pathPrefix="/gaming"
                android:scheme="http" />
            <data
                android:host="example.com"
                android:pathPrefix="/gaming"
                android:scheme="http" />
    
        </intent-filter>
    

    Finally, your code will look as below:

    <activity android:name=".Pages.Splash.SplashPage">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
    
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    
        <!-- DeepLink -->
        <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:host="www.example.com"
                android:pathPrefix="/gaming"
                android:scheme="http" />
            <data
                android:host="example.com"
                android:pathPrefix="/gaming"
                android:scheme="http" />
    
        </intent-filter>
    </activity>