dzep
dzep

Reputation: 695

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 i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
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. 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.

Now, my question is how to return to the previous Activity press I press Back button and if I want to cancel sending mail? Also for the dialog when I want to cancel it.

Upvotes: 0

Views: 493

Answers (1)

mike.b93
mike.b93

Reputation: 1999

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

Upvotes: 1

Related Questions