使用Intent发送电子邮件:仅允许支持附件的电子邮件程序

时间:2015-07-21 14:46:13

标签: android email android-intent attachment

我在尝试限制向Android用户发送电子邮件时向用户发送的电子邮件列表,以支持发送带附件的电子邮件

设置如下; (发送附有图片的电子邮件)

   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) {

   }

不幸的是,这仍然会引发Google Drive和ES File Explorer等程序不支持预期的程序。我们如何将此列表限制为支持发送带附件的电子邮件的程序?

我在下面列出了类似的问题,但他们并没有完全回答我过滤掉允许附件的程序的问题:

0 个答案:

没有答案