Home » Android » android – App Launcher Icon Disappears from screen

android – App Launcher Icon Disappears from screen

Posted by: admin June 15, 2020 Leave a comment

Questions:

I was trying to set the intent filters for a simple app to handle urls. I applied the basic tags for “intent-filter” like “action” ,”category”.

Here I used 2 “intent-filter” tags.

<activity
        android:name=".MyBrowserActivity"
        android:label="@string/app_name" >
        <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" />
           <data android:scheme="http" />
           <category android:name="android.intent.category.BROWSABLE"/>
           <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
</activity>

But the Launcher icon is not shown after instaling if I apply intent filters as shown below in just 1 “intent-filter” tag.

<activity
        android:name=".MyBrowserActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="http" />
            <category android:name="android.intent.category.BROWSABLE"/>
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
</activity>

The main question here I wanted to ask is “Why the app launcher icon disappears in the second case when there is just 1 “intent-filter”.

How to&Answers:

You need to split the intent filter up into two. So you have

<INTENT FILTER>
Action category 
</INTENT FILTER>
<INTENT FILTER>
Action category data
</INTENT FILTER>

Answer:

Split intent-filter into two activities:

    <activity
        android:name=".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:host="main"
                android:scheme="example" />
        </intent-filter>
    </activity>
    <activity
        android:name=".SplashActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

Answer:

As mentioned by @praneetloke, is just to separate into different <intent-filter> groups.
I felt that it was missing an example, so here it goes. Hope it helps.

<activity android:name=".activities.RegisterActivity" android:launchMode="singleTask">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
  <intent-filter  android:autoVerify="true">
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:host="path365.page.link" android:scheme="https"/>
    <data android:host="path365.page.link" android:scheme="http"/>
  </intent-filter>
</activity>