Created
March 23, 2024 15:34
-
-
Save SergeiMikhailovskii/4e96a54d5ba2e06edbd421a94cbcb6e5 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
fun Context.openMarket(deeplink: String, url: String) { | |
val marketAppIntent = Intent(Intent.ACTION_VIEW, Uri.parse(deeplink)).apply { | |
flags += Intent.FLAG_ACTIVITY_NO_HISTORY or | |
Intent.FLAG_ACTIVITY_NEW_DOCUMENT or | |
Intent.FLAG_ACTIVITY_MULTIPLE_TASK | |
} | |
val marketInBrowserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | |
runCatching { | |
startActivity(marketAppIntent) | |
}.getOrElse { | |
startActivity(marketInBrowserIntent) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment