Android Deep Linking

Excellence is not enough!

Android Deep Linking


Notice: Undefined offset: 1 in /home/multithr/public_html/wp-includes/media.php on line 72

Have you ever encountered a situation to connect a http link to your app or just wondered If It’s possible to connect a link to your app , here is the answer :

Deep Linking

So How Does It Work ?

In android we could define Intent Filters for desired Activities that could designate theme-selves to interact with custom url Schemas .

To obtain this we must add following code to our desired Activity in the Manifest :

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

First we put Action View to be distinguishable from Android OS for getting View Intents.

Then we put BROWSABLE category to be accessible from browsers .

And to be responsive to implicit Intents DEFAULT are added .

So We Make A Contract That Makes The Activity Find It’s Designated Uri Format To Be Called .by Adding Data Tag With Host And Scheme Now We Have A Uri Format That Resolves Our Activity And Will Trigger To Launch It.

Then In Your Web Page You Could Add A Link Like This :

myCustomScheme://someUrl.com?AdditionalData=data&AdditionalData2=data2

By Clicking On This Link Your Desired Activity Will Be Launched .

That’s Just It.

If You Want To Read The Data That Uri Contains  Just Get Here Like This :

Intent intent = getIntent();
Uri data = intent.getData();

You Can Parse Uri To Get Every Thing Inside It.

So Where This Tricks Could Be Used ? In My Case I Used It When I Send The User To Web Page Specially To Bank Pages It’s So Useful To Promptly Send The User Back To Desired Activity .