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

查看:207
本文介绍了简单:获取确认在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?

推荐答案

这真的取决于你的意图。这可能是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天全站免登陆