I want to send a HTML email if any mail client is chosen
There is no such way to query about the activities which are used to send only email, Intent.ACTION_SEND
will get all the apps who are able to send the MIME_TYPE
you define.
For instance, if you use plain/text
as MIME_TYPE
, all the client that can share plain/text
will be returned. It is upto user - which app they want to share with. However, you can compare the package name to make sure which app is selected.
Suppose, you want to check if the gmail client is selected,
// Query about app that can send `text/plain`
final Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_TEXT,"text");
final List<ResolveInfo> activities = getPackageManager().queryIntentActivities (i, 0);
// Check if gmail is clicked, when the `chooser` item is clicked,
ResolveInfo info = activities.get(position);
if (info.activityInfo.packageName.contains("com.google.android.gm")) {
// Gmail was chosen
}
When I try to send the HTML email through GMAIL app. It is not
formatted like it supposed to.
Html does not support all the Html tags, You need to write your own tag handler to do so. Check out this link to see what tags are supported by Html.