gpt4 book ai didi

java - 发送电子邮件后如何 toast ?

转载 作者:行者123 更新时间:2023-12-01 19:49:14 27 4
gpt4 key购买 nike

发送邮件后如何 toast ?此编码位于 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();
}
});

如下图所示,Toast 消息会与电子邮件弹出窗口一起出现。

enter image description here

如有任何帮助,我们将不胜感激。

最佳答案

尝试这样

startActivityForResult(Intent.createChooser(sendEmail, "Send mail..."), 0);

在同一 Activity 中接收结果

@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();
}

}

关于java - 发送电子邮件后如何 toast ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52033772/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com