发送电子邮件后如何敬酒一条消息?在onCreate()方法和email.setOnClickListener(new View.OnClickListener()...
else
{
loadingBar.setTitle("Sending Email");
loadingBar.setMessage("Please wait! We are sending your message to the support department.");
loadingBar.show();
Intent sendEmail = new Intent(android.content.Intent.ACTION_SEND);
sendEmail.setType("plain/text");
sendEmail.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"fypadawiyahjalil@gmail.com"});
sendEmail.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
sendEmail.putExtra(android.content.Intent.EXTRA_TEXT,
"Name: " + name + '\n' + "Email: " + email + '\n' + "Message: " + '\n' + message);
startActivity(Intent.createChooser(sendEmail, "Send mail..."));
}
Toast.makeText(ContactUs.this, "Your message has been sent successfully.", Toast.LENGTH_SHORT).show();
}
});
如下图所示,吐司消息随电子邮件一起弹出。
任何帮助将不胜感激。
答案 0 :(得分:2)
尝试这样
startActivityForResult(Intent.createChooser(sendEmail, "Send mail..."), 0);
在同一活动中接收结果
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0) { // Activity.RESULT_OK
Toast.makeText(ContactUs.this, "Your message has been sent successfully.", Toast.LENGTH_SHORT).show();
}
}
答案 1 :(得分:1)
您不能,这不是API的一部分。按下发送按钮后,即使未发送,它也会返回
ACTION_SEND没有任何输出,因此您总会得到默认值RESULT_CANCELED。
此外,您也无法通过返回的Intent数据对其进行检查,因为无论邮件发送还是丢弃,该数据始终为null。