安卓:使用电子邮件的意图发送电子邮件,可能只是在发送之前更改信息? [英] Android: Using email intent to send email, possible to alter message just before sending?

查看:232
本文介绍了安卓:使用电子邮件的意图发送电子邮件,可能只是在发送之前更改信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

发送电子邮件,我需要一些页脚添加到邮件,有没有听众或某种方法,当用户点击发送,我可以编辑短信?

to send email, I need to add some footer to the message, is there any listener or some way that I can edit the message when user clicks "send"?

谢谢!

编辑:

下面是code我用:

private void sendEmail(String recipient, String subject, String message) {
    try {
        final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType("plain/text");
        if (recipient != null)  emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{recipient});
        if (subject != null)    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
        if (message != null)    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);

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

    } catch (ActivityNotFoundException e) {
        // cannot send email for some reason
    }
}

有没有像场:

android.content.Intent.EXTRA_EMAIL

这让我提供信息的目的。

which lets me supply information to the intent.

推荐答案

如果该电子邮件是从自己的应用程序发送的,则需要在的补充页脚的射击的意图。

If the email is sent from your own app, then you will need to add the footer before firing the intent.

如果该电子邮件使用任何其他应用程序(包括默认的电子邮件应用程序)发送的,则没有,你将无法对其进行修改。

If the email is sent using any other app (including the default email app), then no, you won't be able to modify it.

修改

在上面的例子中,你只需要签名附加到的消息字符串,该行之前的任何时间

In the case above, you will just need to append the signature to the message string, any time before the line

if (message != null)    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);

这篇关于安卓:使用电子邮件的意图发送电子邮件,可能只是在发送之前更改信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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