I found various topics here and elsewhere, creating the intention of sending emails, and this seems pretty simple. I am looking for the intention of simply launching any email client that the user may have.
Here is the code that I saw for sending an email ( published for reference only, this does not satisfy my needs since I do not want to send a new message ):
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "Subject of the message");
i.putExtra(Intent.EXTRA_TEXT , "Body of the message");
Here is the code I compiled for a specific Gmail client launch by package name:
PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.google.android.gm");
startActivity(intent);
The code above works, but is not flexible in that the user may not use Gmail, but another embedded email application or a third-party email application. I am looking for an intention that will lead to a choice in this case, so that the user can decide which application will be launched to read email.
Does anyone know how to do this?
source
share