Skip to main content
New Member
July 31, 2024
Question

Set default browser under AMAPI

  • July 31, 2024
  • 0 replies
  • 4 views

We are working with fully managed dedicated devices under Android Manage API and would like to be able have multiple browser app installed but set a default browser using policy.

 

The persistentPreferredActivities seems like the best fit for this and we have successfully used it to set preferred activities for other actions. But so far, attempts to setup a preferred activity for an http/https URL have been unsuccessful.

 

My setup looks something like this:

    "persistentPreferredActivities": [
        {
            "actions": [
                "android.intent.action.VIEW"
            ],
              "categories": [
                "android.intent.category.BROWSABLE",
                "android.intent.category.DEFAULT"
            ],
            "receiverActivity": "com.mybrowser/.BrowserActivity"
        }
]

My "BrowserActivity" is configured to support android.intent.action.VIEW intents.

        <activity
            android:name=".BrowserActivity"
            android:label="@string/title_activity_browser"
            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" />

                <data android:scheme="http" />
                <data android:scheme="https" />
            </intent-filter>
        </activity>

And I can manually set my app as the default browser in Settings. 

 

But if I try to start an activity with an implicit intent to open an http/https URL, it always opens in Chrome.

 

Is this the correct approach to set the default browser under AMAPI or its there another way to do that?