how to get the result of Email Intent? the resultCode isn't correct

c-an :

How can you catch the result of Email Intent?

I tried with this:

val emailIntent = Intent(Intent.ACTION_SEND)
emailIntent.type = "message/rfc822"
emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf("[email protected]"))
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "title")
emailIntent.putExtra(Intent.EXTRA_TEXT, "$sendData")

startActivityForResult(Intent.createChooser(emailIntent, "Send mail..."), RESULT_SEND_EMAIL)                                    

And this doesn't get Activity.RESULT_OK when it sends correctly. Instead, it gets Activity.RESULT_CANCELED.

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)

        if (requestCode == RESULT_SEND_EMAIL) {
            // Make sure the request was successful
            if (resultCode == Activity.RESULT_OK) {
                Toast.makeText(this, "Sending success", Toast.LENGTH_SHORT).show()
            }else{
                Toast.makeText(this, "Sending cancel", Toast.LENGTH_SHORT).show()
                return
            }
        }
    }
CommonsWare :

How can you catch the result of Email Intent?

There is no result. ACTION_SEND has no output.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=319595&siteId=1