Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private fun handleDeepLink() {
val deepLinkUri = intent.data
logd("deepLinkUri: $deepLinkUri")
val deepLinkIntent = deepLinkUri?.let {
DeepLinkInfo.invoke(deepLinkUri).getIntent(this, it)
} ?: DeepLinkInfo.getMainIntent(this)
if (isTaskRoot) {
TaskStackBuilder.create(this).apply {
if (needAddMainForParent(deepLinkIntent)) {
addNextIntentWithParentStack(DeepLinkInfo.getMainIntent(this@SchemeActivity))
}
addNextIntent(deepLinkIntent)
}.startActivities()
} else {
startActivity(deepLinkIntent)
}
finish()
}
private fun needAddMainForParent(intent: Intent): Boolean =
when (intent.component?.className) {
MainActivity::class.java.name -> false
else -> true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment