Links in Android
Links are strings of characters that will take us to some place when it is clicked. There are 3 types of links which you can create in your android app for better user interaction and secure navigation. With the help of links users can land directly on particular content in your app without going through the steps of app-selection and regular app navigation.
There are three types of links are - Deep links, web links and Android app links. Below figure shows the relationship among these links.
Deep Links
Deep links are URIs of any scheme which when clicked will take users to specific part of your app.
URI format - <scheme>://<Authority>/<path>
For example - mytestapp.example.com/location
To implement deep links in the app, follow the below steps:
Add intent filters in the manifest file.
Read the data from incoming intents
Using ADB test your deep links
Intent filters in the manifest file look something as below.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- host name and scheme type from which we will be calling our app -->
<data
android:host="www.gutuku.com"
android:scheme="https" />
</intent-filter>
<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.gutuku.com"
android:scheme="http" />
</intent-filter>
To read data from incoming intents add below code
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main)
val action: String? = intent?.action
val data: Uri? = intent?.data
}
Web Links
Deep links with HTTP and HTTPS schemes are called web links. They are implemented the same way as deep links but in the intent filter we need to provide "http" or "https"
Android App Links
These are web links (http URLs) that are verified to belong to your app only. They use digital assets links API to establish trust between your app and the website.
Implementation Steps:
Add intent filters in the manifest file.
Add code in the activities to read data from incoming links.
Link the app with website using digital asset link.
Check the documentation on how to link the app with website here.