Android Check Intent Can Be Handled Before StartActivity (Kotlin)

April 18, 2018
Check If Activity Available To Handle Intent (prevent ActivityNotFoundException)
if (intent.resolveActivity(activity.packageManager) != null) {
    startActivity(intent)
}
else {
    // prompt a message
}

or

startActivity(Intent.createChooser(intent, "Send email"))
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.