1

I have an EditText, and a Button. The ET is for adding an email address, and the button is for sending the email. I'm trying to accomplish this without any more steps (aka don't want a chooser). Can someone point me in the right direction please, it seems like such a simple thing to do, but every time I try to do this without a chooser, I get an exception.

 Intent i = new Intent(Intent.ACTION_SEND);
                i.setType("message/rfc822");
                i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"user@email.com"});
                i.putExtra(Intent.EXTRA_SUBJECT, "Subject");
                i.putExtra(Intent.EXTRA_TEXT, "some text");
                try {
                    startActivity(i);
                } catch (android.content.ActivityNotFoundException ex) {
                    Toast.makeText(FinalAction.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
                }
  • "I get an exception" -- use LogCat to examine the Java stack trace associated with your crash: https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this Use `ACTION_SENDTO` and a `mailto:` `Uri` when you know the address to which you are sending email. This will limit you to mostly email clients. However, at that point, if the user has more than one email app, **allow the chooser to appear** so the user can choose which email app to use. – CommonsWare Oct 04 '15 at 22:47

0 Answers0