1

I'd like to be able to start installed application, when the user clicks on a URL of a given pattern instead of allowing the browser to open it. This could be when the user is on a web page in the browser.

For example, click on a YouTube link from anywhere in the phone and you'll be given the chance to open the YouTube app, installed before

How do I achieve this for my own app?

Roman
  • 23
  • 4

1 Answers1

2

In Your MyLinkActivity:

String url = getIntent().getDataString();

In your manifest:

<activity
    android:name=".MyLinkActivity">
    <intent-filter>
        <data
            android:host="*.myurl.com"
            android:scheme="http" />
        <data
            android:host="myurl.com"
            android:scheme="http" />
        <data
            android:host="*.myurl.com"
            android:scheme="https" />
        <data
            android:host="myurl.com"
            android:scheme="https" />
                
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <action android:name="android.intent.action.VIEW" />   
    </intent-filter>
</activity>
Dmytro Danylyk
  • 19,684
  • 11
  • 62
  • 68