4

In my app I have an intent filter set to match certain types of links if clicked in a web browser or other field. It currently looks like this:

<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.mydomain.com"
        android:scheme="http" />
    <data
        android:host="mydomain.com"
        android:scheme="http" />
    <data
        android:host="m.mydomain.com"
        android:scheme="http" />
</intent-filter>

This works well. If you click a link say http://www.mydomain.com/article_name then the user gets the option of opening the article in the app and I can show the content uniquely. Here's the question - in the app I want to provide an option for the user to still break out and "Open in Browser". Yet if I do this and just try to fire off an intent to launch the browser, my app catches the link again and we go around in a circle.

How can I specifically force a link to be opened in the browser?

Neil Sainsbury
  • 1,420
  • 3
  • 12
  • 17

2 Answers2

1

I believe you can use the answers provided in this thread to achieve your end. Basically, when you go to launch the "open in browser" intent, you can preview the activities that will be able to open it. From there, you can select one that isn't your app and set that as the package on the intent, which will cause the other app to open it.

At worst, you could force the creation of the chooser which would contain both your app and the other apps that can open your site, enabling the user to pick the browser.

This other question might also be useful, as its answers contain an implementation of a custom chooser which apparently allows you to filter the visible activities, so you could remove your app.

Community
  • 1
  • 1
Jon O
  • 6,532
  • 1
  • 46
  • 57
0

I don't know any way to bypass Android Intent Filter.

If user uses Android default Browser or Chrome, you should use the way in following link to open an Intent specifically.

https://developers.google.com/chrome/mobile/docs/intents

Cuong Huynh
  • 159
  • 6