Sobes.tech
Junior — Middle

How can support for Deep Link be implemented in an app without using third-party libraries?

sobes.tech AI

Answer from AI

To implement Deep Link in Android without third-party libraries, you need to:

  1. Declare an <intent-filter> for the desired Activity in the app manifest with the appropriate schemes and/or hosts:
<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="myapp" android:host="example.com" />
</intent-filter>
  1. In the Activity, get the Intent and extract data from the URI:
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    val data: Uri? = intent?.data
    data?.let {
        // handle the deep link, for example, navigate to the desired screen
    }
}

Thus, when a link like myapp://example.com/somepath is opened, the system will launch your app and pass the URI for processing.