Android Respond To URL in Intent Android Respond To URL in Intent android android

Android Respond To URL in Intent


I did it! Using <intent-filter>. Put the following into your manifest file:

<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.youtube.com" android:scheme="http" /></intent-filter>

This works perfectly!


You might need to allow different combinations of data in your intent filter to get it to work in different cases (http/ vs https/, www. vs no www., etc).

For example, I had to do the following for an app which would open when the user opened a link to Google Drive forms (www.docs.google.com/forms)

Note that path prefix is optional.

        <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="www.docs.google.com" />            <data android:host="docs.google.com" />            <data android:pathPrefix="/forms" />        </intent-filter>