有人可以帮助我,如何弄清楚,如何举杯说“电子邮件已成功发送”或“电子邮件发送失败”的消息吗?
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();
}
}
}
答案 0 :(得分:0)
由于它不是API的一部分,因此目前尚无法实现。
您拥有的代码每次只会返回“邮件已取消”吐司消息。
Intent.ACTION_SEND
将始终返回默认值RESULT_CANCELED
,因为它没有任何输出。
此外,API不知道是否发送了电子邮件,因此它将永远不会返回RESULT_OK
。