Deep Linking And App links with Android

What is deep linking?

Benefit of Deep linking

  • Secure: Universal/App Links use HTTPS URLs that link to a website domain that you own, ensuring that no other app can use your links.
  • Seamless experience: One URL works for both your website and app, ensuring that users can successfully access the content they’re looking for without errors.
  • Increase Engagement: Links can be opened from email clients, search engine results, and more.

Developer support required for deep linking

Why are deep links important?

What is the difference between deep links and app links?

The Building Blocks of Deep Links

  • https — It identifies the protocol used to access the resource on the internet.
  • abhiappmobiledeveloper.medium.com — It is the host, i.e. the domain name or address of the web server that is being accessed.
  • /source— It is the path that specifies a particular page of the content.
  • topics_v2— The query parameter to extract from intents in your destination. topics_v2 is the value of the parameter.

Types of Deep Links

1. Default Deep Links

2. Deferred Deep Links

3. Contextual Deep Linking

Handle deep links in your Android App

//AndroidManifest.xml
<activity android:name=".MainActivity">
<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="abhiappmobiledeveloper.medium.com"/>
</intent-filter>
</activity>
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val textView=findViewById<TextView>(R.id.text)
val action: String? = intent?.action
val data: Uri? = intent?.data

data?.let {
textView.text= "Deep link received - " + data
}

}
}

How to integrate Deep links on Android 12 and Above

<activity
android:name="com.example.MainActivity">
<intent-filter android:autoVerify="true">
// Rest will be same as above implementation
</intent-filter>
</activity>
//update package_name and sha256_cert_fingerprints with yours
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "Your App’s package name",
"sha256_cert_fingerprints": ["Your App’s SHA256 finger print"]
}
}]
https://your domain.com/.well-known/assetlinks.json
  • The assetlinks.json file is served with content-type application/json.
  • The assetlinks.json file must be accessible over an HTTPS connection, regardless of whether your app’s intent filters declare HTTPS as the data scheme.
  • The assetlinks.json file must be accessible without any redirects (no 301 or 302 redirects).
  • Do not publish your app with dev/test URLs in the manifest file that may not be accessible to the public (such as any that are accessible only with a VPN). A work-around in such cases is to configure build variants to generate a different manifest file for dev builds.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhishek Srivastava

Senior Software Engineer | Android | Java | Kotlin |Xamarin Native Android |Flutter |Go