Deep links let your app open specific screens directly from outside, like from a website or another app. This helps users jump straight to what they want.
Deep links in Android Kotlin
<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="www.example.com"
android:pathPrefix="/path" />
</intent-filter>This code goes inside your AndroidManifest.xml under an <activity> tag.
The scheme, host, and pathPrefix define which links open your app.
https://www.shop.com/product/123.<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="www.shop.com"
android:pathPrefix="/product" />
</intent-filter>myapp://open to open your app.<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="open" />
</intent-filter>This activity shows the link used to open the app if any. If opened normally, it shows a default message.
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val data = intent?.data val textView = findViewById<TextView>(R.id.textView) if (data != null) { textView.text = "Opened with link: ${data.toString()}" } else { textView.text = "Opened normally" } } }
Remember to test your deep links by clicking links on your device or using adb commands.
Use adb shell am start -W -a android.intent.action.VIEW -d "https://www.example.com/path/item123" your.package.name to test.
Make sure your app handles the link data safely to avoid crashes.
Deep links let apps open specific screens from outside links.
Define deep links in AndroidManifest.xml with intent filters.
Handle the incoming link data in your activity to show the right content.
Practice
Solution
Step 1: Understand deep link functionality
Deep links allow an app to open a specific screen or content when a user clicks a URL outside the app.Step 2: Compare options with this purpose
Only To open a specific screen inside the app from an external URL describes opening a specific screen from an external URL, which matches deep link behavior.Final Answer:
To open a specific screen inside the app from an external URL -> Option AQuick Check:
Deep link purpose = open specific screen [OK]
- Confusing deep links with UI styling
- Thinking deep links change app icons
- Assuming deep links increase memory
Solution
Step 1: Identify where deep links are declared
Deep links are declared inside an element within an activity in AndroidManifest.xml.Step 2: Match options to this element
Only is used to specify deep link URL patterns and actions.Final Answer:
<intent-filter> -> Option BQuick Check:
Deep links declared in intent-filter [OK]
- Confusing activity tag with deep link declaration
- Using service or provider tags incorrectly
- Not nesting intent-filter inside activity
<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="example.com" android:pathPrefix="/profile" /> </intent-filter>
Solution
Step 1: Analyze the intent filter data attributes
The scheme is https, host is example.com, and pathPrefix is /profile, so URLs starting with https://example.com/profile will match.Step 2: Check each option against these rules
https://example.com/profile/settings matches https scheme, example.com host, and path starting with /profile. Options B (http scheme), C (wrong path), and D (wrong host) do not match.Final Answer:
https://example.com/profile/settings -> Option CQuick Check:
Match scheme, host, pathPrefix = https://example.com/profile/settings [OK]
- Ignoring scheme (http vs https)
- Confusing host names
- Not checking pathPrefix carefully
<intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.LAUNCHER" /> <data android:scheme="myapp" /> </intent-filter>
Solution
Step 1: Check required categories for deep links
Deep links require the BROWSABLE category to allow opening from browsers or external apps.Step 2: Identify incorrect category usage
This intent filter uses LAUNCHER category, which is for app launchers, not deep links.Final Answer:
It uses LAUNCHER category instead of BROWSABLE -> Option AQuick Check:
Deep links need BROWSABLE category [OK]
- Using LAUNCHER category for deep links
- Forgetting to add BROWSABLE category
- Placing intent-filter inside wrong tag
myapp://user/123 is clicked. Which intent filter correctly handles this deep link?Solution
Step 1: Check required action and categories for deep links
Deep links need action VIEW and categories DEFAULT and BROWSABLE to work properly.Step 2: Verify data attributes match the URL pattern
The URL myapp://user/123 has scheme="myapp", host="user", path="/123". Needs matching scheme, host, and pathPattern="/.*" for variable IDs.Step 3: Compare options
The filter with scheme="myapp", host="user", pathPattern="/.*", VIEW action, DEFAULT and BROWSABLE matches perfectly. pathPrefix="/user" without host mismatches path="/123". Missing BROWSABLE limits external opening. MAIN/LAUNCHER is incorrect for deep links.Final Answer:
Intent filter with VIEW action, DEFAULT/BROWSABLE categories, scheme myapp, host user, pathPattern /.* -> Option DQuick Check:
scheme=myapp host=user pathPattern=/.* VIEW BROWSABLE [OK]
- Missing BROWSABLE category
- Using MAIN action instead of VIEW
- Confusing pathPrefix with host+pathPattern
- Wrong categories for deep links
Ready to prove it?
Pass the test and this pattern moves unknown
