I'm trying to limit the program list presented to the user when sending an email with Intents in Android to ones that support sending an email with an attachment.
This is setup as follows; (sending an email with a pic attached)
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("message/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, EMAIL_SUBJECT);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(EMAIL_BODY));
setupImageForSharing();
Uri uri = Uri.fromFile(casted_image);
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
try {
startActivity(Intent.createChooser(emailIntent, "Send Email."));
if (mListner != null) {
mListner.shared(true);
mListner = null;
}
} catch (Exception ex) {
}
This unfortunately still throws up programs such as Google Drive and ES File Explorer which do not support what is expected. How could we limit this list to programs that support sending an email with an attachment?
There are similar questions I've found listed below, but they do not quite answer my issue of filtering out programs which allow attachments: