# Android: Deep Linking
###### tags: `Android` `Deep Linking` `URL to APP`
[TOC]
## What is Deep Linking?
To make explanation simple and short, it would be how to link a URL to your Application.
>**Why Use Deep Linking?**
Sometimes we just wish that users can just open something with our installed apps, so in order to increase usage we use deep linking. [color=red]
## How to set Deep Linking?
The Steps are:
1. Set **Intent-Filter** in Manifest.
2. Deal Activity and URL
### Step 1: Set **Intent-Filter** in Manifest
The Steps are:
1. Choose an activity you want to open with URL.
2. Configure the Android URI Scheme
>**Android URI Scheme**
>This is what we set when we want to define what URL we are listening to.
In this case it is defined by using <data/> scheme, host, pathPrefix [color=lightBlue]
3. Remember to define it as **BROWSABLE**, which means it is an outer URL to APP.
*Note*: Deep Linking can be from APP to APP too.
>**Note:** [color=pink]
>App will ***ONLY*** be opened if it is installed.
You will be asked everytime what application/program you want to open the URL with, unless you select to open it by any method forever.
**Manifest Intent-Filter:**
```java==
<activity
android:name=".VideoActivity">
<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="https"
android:host="@string/host_name"
android:pathPrefix="/video"/>
</intent-filter>
</activity>
```
### Step 2: Deal Activity and URL
Sometimes you need some variables or parts of the url to start your activity.
With the method below, you can get any parts of the URL.
>The url in this case is **https: //urlBody/v10**. [color=orange]
```java=
private void dealOuterLink(){
Uri dataWeb = getIntent().getData();
if(dataWeb != null && dataWeb.isHierarchical()){
String uri = getIntent().getDataString();
uri = uri.substring(uri.lastIndexOf('v') + 1);
controller.getVideoInfo(uri);
}
}
```
## Useful Links
>**Deep Linking Guide**
URL: https://blog.branch.io/updated-for-2019-the-ultimate-android-deep-linking-guide/ [color=#187fce]