0

How to inspect an intent to see if it was an intent that started/launched the app versus an intent that was used to navigate from within the app or once the app was already opened?

We have special UI handling based on if the intent was launched using a deeplink that doesn't work well if the app is launched from a deeplink. Right now, I am adding an extra boolean to the intent to workaround the issue we have, but was wondering if there was something available in the framework/SDK to determine if a particular intent was the app start/launch intent.

NOTE: We are using jetpack navigation to handle incoming intents/deeplinks and to route deeplinks within the app. That is why in the snippet below you can see I am accessing the intent from currentBackStackEntry

Here is the code I've put in to support it so far:

In MainActivity onCreate

        intent.putExtra(KEY_IS_APP_CREATED_INTENT, true)

In our UI logic code

val isAppCreationIntent = navController.currentBackStackEntry?.arguments
    ?.parcelable<Intent>(KEY_DEEP_LINK_INTENT)
    ?.getBooleanExtra(KEY_IS_APP_CREATED_INTENT, false) ?: false

I logged a bug/feature request to provide this capability here:

https://issuetracker.google.com/u/1/issues/265981498

dazza5000
  • 7,075
  • 9
  • 44
  • 89

0 Answers0