2

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:

Community
  • 1
  • 1
Madhu
  • 2,429
  • 16
  • 31
  • Have you an example email client that doesn't support attachments? – Rowland Shaw Jul 21 '15 at 14:53
  • Use Intent.ACTION_SENDTO http://developer.android.com/reference/android/content/Intent.html#ACTION_SENDTO – Ufkoku Jul 21 '15 at 15:06
  • @RowlandShaw: Not really, I phrased the question with the attachment in mind, since some of the proposed solutions to narrow the list down to email clients did not seem to do the job. – Madhu Jul 22 '15 at 01:52
  • @Ufkoku: I'll look into that, thanks. – Madhu Jul 22 '15 at 01:52
  • @Madhu there are plenty of solutions on those questions on limiting to an email client (mostly revolving around building a mailto: URI), which is why I wondered what client was causing you problems that you needed to *additionally* exclude. – Rowland Shaw Jul 22 '15 at 09:15

0 Answers0