如何获得Email Intent的结果?结果代码不正确
how to get the result of Email Intent? the resultCode isn't correct
如何捕捉 Email Intent 的结果?
我试过这个:
val emailIntent = Intent(Intent.ACTION_SEND)
emailIntent.type = "message/rfc822"
emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf("xxxx@gmail.com"))
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "title")
emailIntent.putExtra(Intent.EXTRA_TEXT, "$sendData")
startActivityForResult(Intent.createChooser(emailIntent, "Send mail..."), RESULT_SEND_EMAIL)
当它正确发送时,它不会得到 Activity.RESULT_OK
。相反,它得到 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
}
}
}
How can you catch the result of Email Intent?
没有结果。 ACTION_SEND
has no output.
如何捕捉 Email Intent 的结果?
我试过这个:
val emailIntent = Intent(Intent.ACTION_SEND)
emailIntent.type = "message/rfc822"
emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf("xxxx@gmail.com"))
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "title")
emailIntent.putExtra(Intent.EXTRA_TEXT, "$sendData")
startActivityForResult(Intent.createChooser(emailIntent, "Send mail..."), RESULT_SEND_EMAIL)
当它正确发送时,它不会得到 Activity.RESULT_OK
。相反,它得到 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
}
}
}
How can you catch the result of Email Intent?
没有结果。 ACTION_SEND
has no output.