[英]Sending Email Goes Back to Home Screen
So, I have this code to create an email Intent
so my users can send support mail. 因此,我有此代码来创建电子邮件
Intent
以便我的用户可以发送支持邮件。
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"username@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "The subject");
i.putExtra(Intent.EXTRA_TEXT, "The body");
startActivity(Intent.createChooser(i, "Send email"));
With that code, it opens up a dialog where I will choose which app will I use to send email. 使用该代码,它将打开一个对话框,在该对话框中,我将选择用于发送电子邮件的应用程序。 When I press the
Back button
, it returns to Home screen
and also if I tap to somewhere else to close the dialog. 当我按下“
Back button
,它将返回Home screen
,并且如果我点击其他位置以关闭对话框。 And when I choose an app, Gmail for example, it opens up Gmail (I can now send email), but when I press send it also goes back to Home screen
and also if I press the Back button
. 而且,当我选择一个应用程序(例如Gmail)时,它会打开Gmail(我现在可以发送电子邮件)了,但是当我按“发送”时,它也会返回到
Home screen
,并且如果我按了“ Back button
,也会Back button
。
Now, my question is how to return to the previous Activity
press I press Back button
and if I want to cancel sending mail? 现在,我的问题是如何返回上一个“
Activity
然后按“ Back button
,是否要取消发送邮件? Also for the dialog when I want to cancel it. 当我想取消对话框时也适用。
Try this for Email, filters way better: 尝试使用此电子邮件,可以更好地过滤:
Intent feedback = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + "SUBJECT"
+ "&body=" + "BODY" + "&to="
+ "EMAILADRESS");
feedback.setData(data);
startActivity(feedback);
This did a great job for me 这对我来说很棒
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.