How to send emails from my Android application?

前端 未结 21 2801
春和景丽
春和景丽 2020-11-22 00:38

I am developing an application in Android. I don\'t know how to send an email from the application?

21条回答
  •  情书的邮戳
    2020-11-22 00:45

    I've been using this since long time ago and it seems good, no non-email apps showing up. Just another way to send a send email intent:

    Intent intent = new Intent(Intent.ACTION_SENDTO); // it's not ACTION_SEND
    intent.putExtra(Intent.EXTRA_SUBJECT, "Subject of email");
    intent.putExtra(Intent.EXTRA_TEXT, "Body of email");
    intent.setData(Uri.parse("mailto:default@recipient.com")); // or just "mailto:" for blank
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this will make such that when user returns to your app, your app is displayed, instead of the email app.
    startActivity(intent);
    

提交回复
热议问题