【问题标题】:How to toast a message said that the "email message has been sent successfully"?如何敬酒说“邮件已发送成功”?
【发布时间】:2019-01-20 00:53:42
【问题描述】:

谁能帮帮我,如何弄清楚,如何敬酒说“邮件已发送成功”或“邮件发送失败”?

Intent sendEmail = new Intent(Intent.ACTION_SEND);

sendEmail.setType("plain/text");
sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[]{"fypadawiyahjalil@gmail.com"});
sendEmail.putExtra(Intent.EXTRA_SUBJECT, subject);
sendEmail.putExtra(Intent.EXTRA_TEXT,
        "Name: "+name+'\n'+"Email: "+email+'\n'+"Message: "+'\n'+message);

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

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);

    if(requestCode==1)
    {
        if(requestCode == 1 && resultCode == Activity.RESULT_OK)
        {
            Toast.makeText(ContactUs.this, "Your message has been sent successfully.", Toast.LENGTH_SHORT).show();
            loadingBar.dismiss();
        }
        else if (requestCode == 1 && resultCode == Activity.RESULT_CANCELED)
        {
            Toast.makeText(ContactUs.this, "Mail cancelled.", Toast.LENGTH_SHORT).show();
            loadingBar.dismiss();
        }
        else
        {
            Toast.makeText(ContactUs.this, "Please try again.", Toast.LENGTH_SHORT).show();
            loadingBar.dismiss();
        }
    }
}

【问题讨论】:

    标签: java android email android-intent sendmail


    【解决方案1】:

    目前无法这样做,因为它不是 API 的一部分。

    您拥有的代码每次只会返回“邮件已取消”的 toast 消息。

    Intent.ACTION_SEND 将始终返回默认值 RESULT_CANCELED,因为它没有任何输出。

    此外,API 不知道是否发送了电子邮件,因此它永远不会返回 RESULT_OK

    【讨论】:

    • 那我是不是应该继续给消息敬酒?
    • 很遗憾,目前没有解决方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-12
    • 1970-01-01
    • 2017-07-09
    • 2019-11-24
    • 2014-01-16
    • 1970-01-01
    • 2011-01-21
    相关资源
    最近更新 更多