6

I don't want to send emails to other users. I only want to open the launching activity of Email. I have tried it through different ways but every time send email(compose) is opening. But i want to open Email app only nothing else(Sent, outbox, spam, Trash etc).

My code is below

Intent intent = new Intent(Intent.ACTION_SENDTO)
    .setData(Uri.parse("mailto:"));

//check if the target app is available or not

if (intent.resolveActivity(getPackageManager()) != null) {
    startActivity(intent);
}

Again, This code opens the send email to(compose) option. But i want to open Email app only nothing else(Sent, outbox, spam, Trash etc).

name not found
  • 622
  • 4
  • 13
Shoaib Kakal
  • 1,090
  • 2
  • 16
  • 32
  • Hi, why your account is temporarily suspended? What did you do that this happened? – MMG May 09 '20 at 06:59
  • I got a chance to review questions after 500 reps. but I was skipping without any reason, this is what Moderator gave me the reason. lol – Shoaib Kakal May 11 '20 at 03:56

1 Answers1

15

Use this code to open default Mail Application :

try {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_APP_EMAIL);
    this.startActivity(intent);
} catch (android.content.ActivityNotFoundException e) {
    Toast.makeText(Dashboard.this, "There is no email client installed.", Toast.LENGTH_SHORT).show();
}
Vishal Nagvadiya
  • 1,178
  • 12
  • 15