Tuesday 12 July 2016

Opening Android App When Particular link/Host with Scheme is opened in Browser.

Opening Android Application when particular "Host" is opened in Android mobile browser or particular Link is opened Also named as Mobile DeepLinking.

We need to define host & scheme in the intent filters of the activity, which we need to open when link or host is opened.


Below is the code for opening app when particular Host is opened.

 <activity


            android:name=".ActivityName">
<intent-filter>

                <action android:name="android.intent.action.GALLERY" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
<data
                    android:host="http"
                    android:scheme="abc.com" /> 
</intent-filter>

</activity>

Below is the code for opening app when we are trying particular Link  in browser.


 <activity

        android:name=".ActivityName">
        <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"
                  android:host="abc.com"
                  android:pathPrefix="/images/" />
            <data android:scheme="https"
                  android:host="abc.com"
                  android:pathPrefix="/images/" />
        </intent-filter>
   </activity>
 
   
Cheers!!   

No comments:

Post a Comment