如何获得电子邮件意图的结果?结果代码不正确



如何获取电子邮件意向的结果?

我试过这个:

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
}
}
}

如何获取电子邮件意向的结果?

没有结果。ACTION_SEND没有输出。

相关内容

  • 没有找到相关文章