Skip to content

Instantly share code, notes, and snippets.

@victorbrndls
Last active May 16, 2021 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorbrndls/157978afa5b67f13f6f5fc1e47cc38e7 to your computer and use it in GitHub Desktop.
Save victorbrndls/157978afa5b67f13f6f5fc1e47cc38e7 to your computer and use it in GitHub Desktop.
fun Context.isResolvable(intent: Intent) = intent.resolveActivity(packageManager) != null
fun Context.view(uri: Uri, onAppMissing: () -> Unit) {
val intent = Intent(Intent.ACTION_VIEW, uri)
if (!isResolvable(intent)) {
onAppMissing()
return
}
startActivity(intent)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment