I have found various topics here and elsewhere on creating an intent for sending e-mail and that seems to be pretty straightforward. I'm looking for an intent to just launch any e-mail client the user might have.
Here is the code I've seen for sending an e-mail (posted just for reference, this doesn't serve my needs as I don't want to send a new message):
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"[email protected]"});
i.putExtra(Intent.EXTRA_SUBJECT, "Subject of the message");
i.putExtra(Intent.EXTRA_TEXT , "Body of the message");
Here is the code I put together for specifically launching the Gmail client by package name:
PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.google.android.gm");
startActivity(intent);
The code above works but isn't flexible in that a user might not be using Gmail but the other built-in e-mail application or a 3rd party e-mail app. I'm looking for an intent that would bring up the chooser in this case so the user can decide which app to launch to read e-mail.
Does anyone know how to accomplish this?