Home > Software design >  I cant run the email intent code on my phone
I cant run the email intent code on my phone

Time:09-23

sent email screenshot

How to fix your problem

In general, I think we should do these as below.

  1. Check the log in the Logcat panel in Android Studio, maybe there are exceptions.
  2. Added your debug code where you want to add.

CodePudding user response:

val i = Intent(Intent.ACTION_SEND)
    i.type = "message/rfc822"
    i.putExtra(Intent.EXTRA_EMAIL, arrayOf<String>("[email protected]"))
    i.putExtra(Intent.EXTRA_SUBJECT, "Feedback")
    i.putExtra(Intent.EXTRA_TEXT, "Text here...")
    try {
        startActivity(Intent.createChooser(i, "Send mail..."))
    } catch (ex: ActivityNotFoundException) {
        Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT)
            .show()
    }
  • Related