Add my browser in the default browser selection list in android?

Gokul N K :

Following the suggestions from How to add my browser in the default browser selection list in android?. I have specified my Intent in the manifest file:

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http"/> 
<data android:scheme="https"/> 
</intent-filter>

I have also added the permission:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

But still my browser is not showing in the default app options for the browser category in the settings.

Do I need to do anything else for my app to show up in the default options for browser?

aminography :

Try to include the <category android:name="android.intent.category.BROWSABLE" /> in your target activity's intent-filter as developer documentation said:

If the user is viewing a web page or an e-mail and clicks on a link in the text, the Intent generated execute that link will require the BROWSABLE category, so that only activities supporting this category will be considered as possible actions.

It is required in order for the intent-filter to be accessible from a clickable link. Without it, clicking a link cannot resolve to your app.

<activity ...>

    <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="http" />
        <data android:scheme="https" />
    </intent-filter>

</activity>

.

Additional Tip: (If you want to force your app to be the default browser)

Android App Links on Android 6.0 (API level 23) and higher allow an app to designate itself as the default handler of a given type of link. If the user doesn't want the app to be the default handler, they can override this behavior from their device's system settings.

To enable link handling verification for your app, set android:autoVerify="true" in intent-filter tag:

<activity ...>

    <intent-filter android:autoVerify="true">

         ...

    </intent-filter>

</activity>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=36883&siteId=1