How to make a the links of my website in the Android browser start up my app but not when the link has a Certain part

Question

I'm going to implement this scenario:

www. example.com -> Start up my App

http:// example.com -> Start up my App

http:// www.example.com -> Start up my App

https:// example.com -> Start up my App

https:// www.example.com -> Start up my App

But...

http:// example.com/dont/start/app -> Open the link in default browser.

by using intent-filter all the times it will open my app.

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name">
        <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" />
            <data android:host="example.com" />
        </intent-filter>
    </activity>

Show source
| url   | java   | android   | website   | intentfilter   2017-01-07 17:01 1 Answers

Answers to How to make a the links of my website in the Android browser start up my app but not when the link has a Certain part ( 1 )

  1. 2017-01-07 17:01

    One way to do it would be to open the browser directly in that case. Like this

    onCreate() {
      if(uri is in path we don't want) {
        open browser directly via intent
        finish();
        return;
      }
      //Handle a URL we do want
    }
    

    To open the browser directly, you can figure out what the default browser is via How to find default browser set on android device and launch it explicitly.

Leave a reply to - How to make a the links of my website in the Android browser start up my app but not when the link has a Certain part

◀ Go back