Skip to content

Instantly share code, notes, and snippets.

@jtmuller5
Created June 5, 2020 03:27
Show Gist options
  • Save jtmuller5/bcb4697201f6a6a06697e8892967588a to your computer and use it in GitHub Desktop.
Save jtmuller5/bcb4697201f6a6a06697e8892967588a to your computer and use it in GitHub Desktop.
Handle Intent from Custom Tab
// Handle any possible intents **************************************************************************
// The URL is stored in the intent's data
val data: Uri? = intent?.data
// Figure out what to do based on the intent type
if (intent?.type?.startsWith("image/") == true) {
// Handle intents with image data ...
Log.d("Intent",intent?.type.toString())
} else if (intent?.type == "text/plain") {
// Handle intents with text ...
Log.d("Intent.text",intent.extras?.getString("android.intent.extra.TEXT").toString())
}else{
if (data != null) {
Log.d("Intent URL",data.toString())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment