琐碎:获取在 android 中发送的电子邮件的确认 [英] Trivial: Get confirmation of email sent in android

查看:23
本文介绍了琐碎:获取在 android 中发送的电子邮件的确认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在启动电子邮件意图后,我如何才能确认电子邮件已发送或在调用它的活动中出现错误?

After starting an email intent how can I get confirmation that the email has sent or there has been an error back into the activity it was called from?

        Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.setType("png/image");

        String subject = "Email Subject";

        String body = "Message Body"; 

        emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        emailIntent.putExtra(Intent.EXTRA_TEXT, body);
        emailIntent.putExtra(Intent.EXTRA_STREAM,
                Uri.parse("file:///sdcard/" + IMAGE_FILENAME));

        startActivity(Intent.createChooser(emailIntent, "Send email...")); 

        //Here I need to do something on a successfully sent email

也许开始activityForResult?但如果有的话,我应该期待什么结果?

Maybe start activityForResult? But what result should I expect back if any?

推荐答案

这实际上取决于您的 Intent 启动的应用程序.它可以是 Gmail 应用程序,也可以是电子邮件应用程序,也可以是任何第三方应用程序.因此,没有 100% 可靠的方法来确定用户是否真的按下了发送.

That really depends on the app that is launched by your Intent. It could be the Gmail app, it could be the Email app, or it could be any third-party app. Because of this, there is no 100% reliable way to determine whether the user actually pressed Send or not.

您唯一能做的就是检查 Gmail 和电子邮件应用程序在通过 startActivityForResult 调用时是否返回任何相关信息,并以此为依据.但请注意,这并不可靠,因为同样可能存在第三方应用程序.此外,由于这些应用没有公开指定它们返回的内容,因此它们可能会在某个时候更改,恕不另行通知.

The only thing you can do is check if the Gmail and Email apps return anything relevant when called via startActivityForResult and rely on that. But beware that is not reliable because, again, there could be third party apps. Also, since these apps do not specify publicly what they return, they might change that at some point without any notice.

这篇关于琐碎:获取在 android 中发送的电子邮件的确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆