I am developing an app right now that has email functionality. My problem is with the intent.createChooser not giving the proper options to the user.
fun send(context: Context) {
val mIntent = Intent(Intent.ACTION_SEND)
mIntent.type = "text/plain"
mIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf("[email protected]"))
mIntent.putExtra(Intent.EXTRA_SUBJECT, _contactUiState.value.subject)
mIntent.putExtra(Intent.EXTRA_TEXT, _contactUiState.value.message)
try {
context.startActivity(Intent.createChooser(mIntent, "Send Email"))
} catch (e: Exception) {
Log.e("Main", e.message!!)
}
}
The problem I'm having is that setting mIntent.type to "text/plain" gives options that isn't an email client. Setting mIntent.data to Uri.parse("mailto:") makes it so that options don't come up and it just chooses one for you. Setting both of them gives 0 options. How can I make it so that the only options that show up are email clients?