0
0
Android Kotlinmobile~20 mins

Deep links in Android Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Deep Link Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What happens when a deep link is triggered?
Consider an Android app with a deep link configured to open a specific screen. What is the expected behavior when the deep link URL is clicked?
AThe app opens the home screen of the device instead of the app.
BThe app opens the launcher screen first, then navigates to the specified screen after a delay.
CThe app opens directly to the specified screen without showing the launcher or home screen.
DThe app crashes because deep links are not supported by default.
Attempts:
2 left
💡 Hint
Think about what deep links are designed to do: take users straight to content.
🧠 Conceptual
intermediate
2:00remaining
Which AndroidManifest.xml element defines a deep link?
In Android development, which element inside the AndroidManifest.xml file is used to declare a deep link for an activity?
A<meta-data> with the deep link URI inside
B<service> with <intent-filter> specifying the deep link URI
C<provider> with <data> specifying the deep link URI
D<intent-filter> with <action android:name="android.intent.action.VIEW"/> and <data> specifying the URI
Attempts:
2 left
💡 Hint
Deep links are triggered by intents targeting activities.
lifecycle
advanced
2:00remaining
What lifecycle method is called when an activity is opened via a deep link?
When an Android activity is opened through a deep link while the app is already running, which lifecycle method is called to handle the new intent?
AonNewIntent(Intent intent)
BonCreate(Bundle savedInstanceState)
ConStart()
DonResume()
Attempts:
2 left
💡 Hint
Think about how Android delivers new intents to existing activities.
🔧 Debug
advanced
2:00remaining
Why does this deep link not open the app?
An app has this intent filter in AndroidManifest.xml: Clicking the URL http://example.com/open/page does not open the app. Why?
AThe pathPrefix matches "/open" and all subpaths, so the problem is elsewhere.
BThe intent filter is missing the android:port attribute, so it won't match URLs with ports.
CThe app is not installed, so the deep link cannot open it.
DThe pathPrefix "/open" does not match "/open/page" because pathPrefix matches only the exact path.
Attempts:
2 left
💡 Hint
Check how pathPrefix matching works in Android deep links.
navigation
expert
3:00remaining
How to handle multiple deep links with different parameters in one activity?
You want one activity to handle deep links like myapp://product/123 and myapp://category/456. How should you configure the intent filter and handle navigation in Kotlin?
Android Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  val data = intent?.data
  when {
    data?.pathSegments?.getOrNull(0) == "product" -> {
      val productId = data.pathSegments[1]
      // Navigate to product screen with productId
    }
    data?.pathSegments?.getOrNull(0) == "category" -> {
      val categoryId = data.pathSegments[1]
      // Navigate to category screen with categoryId
    }
  }
}
ACreate separate activities for product and category and separate intent filters for each URI pattern.
BUse one intent filter with <data android:scheme="myapp" /> and parse pathSegments in onCreate to route accordingly.
CUse multiple intent filters with different schemes for product and category URIs.
DHandle deep links only in the launcher activity and ignore intent filters.
Attempts:
2 left
💡 Hint
One activity can handle multiple deep link paths by parsing the URI.