0
0
Android Kotlinmobile~10 mins

Deep links in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an intent filter for a deep link in AndroidManifest.xml.

Android Kotlin
<intent-filter>
    <action android:name="[1]" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
Drag options to blanks, or click blank then click option'
Aandroid.intent.action.CALL
Bandroid.intent.action.MAIN
Candroid.intent.action.SEND
Dandroid.intent.action.VIEW
Attempts:
3 left
💡 Hint
Common Mistakes
Using MAIN action instead of VIEW.
Forgetting to include BROWSABLE category.
2fill in blank
medium

Complete the code to specify the scheme for a deep link in the intent filter.

Android Kotlin
<data android:scheme="[1]" />
Drag options to blanks, or click blank then click option'
Aftp
Bhttp
Cfile
Dmailto
Attempts:
3 left
💡 Hint
Common Mistakes
Using ftp or mailto which are not common for app deep links.
Confusing file scheme with web URLs.
3fill in blank
hard

Fix the error in the Kotlin code to handle the deep link intent in an Activity.

Android Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    val intent = [1]
    val data = intent?.data
    if (data != null) {
        // Handle the deep link
    }
}
Drag options to blanks, or click blank then click option'
Aintent
BgetIntent()
CgetIntent
DgetIntentData()
Attempts:
3 left
💡 Hint
Common Mistakes
Using getIntent() which is Java syntax.
Using a non-existent method getIntentData().
4fill in blank
hard

Fill both blanks to declare a deep link intent filter with host and path prefix.

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="[1]" android:pathPrefix="[2]" />
</intent-filter>
Drag options to blanks, or click blank then click option'
Awww.example.com
B/products
Cexample.com
D/home
Attempts:
3 left
💡 Hint
Common Mistakes
Using www in host which can cause mismatch.
Using incorrect path prefix without leading slash.
5fill in blank
hard

Fill all three blanks to create a Kotlin function that extracts a query parameter named 'id' from a deep link Uri.

Android Kotlin
fun getIdFromDeepLink(intent: Intent): String? {
    val data = intent.data
    return data?.[1]("[2]") ?: [3]
}
Drag options to blanks, or click blank then click option'
AgetQueryParameter
Bid
Cnull
DgetQuery
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent method like getQuery.
Returning an empty string instead of null.