Created
February 11, 2020 16:46
-
-
Save ParkSangGwon/ae671c1fcd9f7d80fafc7d15e882f441 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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