android - 如何获得电子邮件意图的结果?结果代码不正确
问题描述
您如何捕获电子邮件意图的结果?
我试过这个:
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
没有输出。
推荐阅读
- sql - 为什么sql减两个冒号
- reactjs - React浅层测试中硬编码的预期字符串与提取的变量
- javascript - 无法使用 JavaScript 使元素返回其原始状态
- ruby - Ruby 从字符串中删除插值
- matlab - MATLAB 正确使用 fread() 和 float32
- javascript - 在.net中动态生成ID时如何解决无效的查询选择器
- c++ - C++ 如何检测 Windows Server 2019?
- python - 无法按名称找到元素
- dialogflow-es - 如何通过 V2 客户端库为节点 js 创建 OutPutContext
- python - 在 Selenium 网页中单击“显示更多交易”