Android 多张照片未使用Intent发送到gmail

Android 多张照片未使用Intent发送到gmail,android,Android,我是android新手,尝试使用Intent将多个文件发送到gmail。但它不发送附件。请帮我做这个 以下是我的代码: Intent targetedShare = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); targetedShare.setType("image/*"); // put here your mime type targetedShare.putExtra(Intent.EX

我是android新手,尝试使用Intent将多个文件发送到gmail。但它不发送附件。请帮我做这个

以下是我的代码:

Intent targetedShare = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
        targetedShare.setType("image/*"); // put here your mime type

        targetedShare.putExtra(Intent.EXTRA_SUBJECT, "Amplimesh Photo");
        targetedShare.putExtra(Intent.EXTRA_TEXT,"Attached the Quote");

        ArrayList<Uri> uris = new ArrayList<Uri>();

        //Fetching the Installed App and open the Gmail App.
        for(int index = 0; index < productList.size(); index++) {
            ByteArrayInputStream byteInputStream = new ByteArrayInputStream(productList.get(index).getOverlayBitmap());
            Bitmap overLayBitmap = BitmapFactory.decodeStream(byteInputStream);

            String fileName = SystemClock.currentThreadTimeMillis() + ".png";

            //Save the bitmap to cache.
            boolean isSaved = Helper.saveImageToExternalStorage(overLayBitmap, getApplicationContext(), fileName);
            if(isSaved)
                uris.add(Uri.fromFile(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/amplimesh", fileName)));
        }
        targetedShare.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        startActivityForResult(Intent.createChooser(targetedShare, "Sending multiple attachment"), 12345);
Intent targetedShare=新的意图(android.content.Intent.ACTION\u SEND\u MULTIPLE);
targetedShare.setType(“image/*”);//把你的mime类型放在这里
targetedShare.putExtra(Intent.EXTRA_主题,“Amplimesh照片”);
targetedShare.putExtra(意图.额外文本,“随附报价”);
ArrayList URI=新的ArrayList();
//获取已安装的应用程序并打开Gmail应用程序。
对于(int index=0;index
更新

尝试这样的完整路径

uris.add(Uri.fromFile(new File(Environment.getExternalStorageDirectory()+"/foldername/certi/qualifications.jpg")));
用这个

Intent share = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); 
而不是

Intent share = new Intent(android.content.Intent.ACTION_SEND);
试试这个

 Intent ei = new Intent(Intent.ACTION_SEND_MULTIPLE);
            ei.setType("plain/text");
            ei.putExtra(Intent.EXTRA_EMAIL, new String[] {"email id"});
            ei.putExtra(Intent.EXTRA_SUBJECT, "That one works");

            ArrayList<String> fileList = new ArrayList<String>();
            fileList.add(Environment.getExternalStorageDirectory()+"/foldername/certi/qualifications.jpg");
            fileList.add(Environment.getExternalStorageDirectory()+"/foldername/certi/certificate.jpg");
            fileList.add(Environment.getExternalStorageDirectory()+"/foldername/Aa.pdf");

            ArrayList<Uri> uris = new ArrayList<Uri>();
            //convert from paths to Android friendly Parcelable Uri's

            for (int i=0;i<fileList.size();i++)
            {
                File fileIn = new File(fileList.get(i));
                Uri u = Uri.fromFile(fileIn);
                uris.add(u);
            }

            ei.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            startActivityForResult(Intent.createChooser(ei, "Sending multiple attachment"), 12345);
Intent ei=新意图(Intent.ACTION\u SEND\u MULTIPLE);
ei.设置类型(“纯/文本”);
ei.putExtra(Intent.EXTRA_EMAIL,新字符串[]{“EMAIL id”});
ei.putExtra(Intent.EXTRA_主题,“那一个有效”);
ArrayList fileList=新建ArrayList();
add(Environment.getExternalStorageDirectory()+“/foldername/certi/qualifications.jpg”);
add(Environment.getExternalStorageDirectory()+“/foldername/certi/certificate.jpg”);
添加(Environment.getExternalStorageDirectory()+“/foldername/Aa.pdf”);
ArrayList URI=新的ArrayList();
//从路径转换为Android友好的包裹Uri

对于(inti=0;i,这里是我们的prj中的示例工作代码

ArrayList<Uri> imageUris = new ArrayList<Uri>();
imageUris.add(Uri.fromFile(new File("/mnt/sdcard/Medplann/IMG.jpg"))); // Add your image URIs here
imageUris.add(Uri.fromFile(new File("/mnt/sdcard/Medplann/Report.pdf")));

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share images to.."));
ArrayList imageUris=new ArrayList();
imageUris.add(Uri.fromFile(新文件(“/mnt/sdcard/Medplann/IMG.jpg”);//在此处添加图像Uri
add(Uri.fromFile(新文件(“/mnt/sdcard/Medplann/Report.pdf”);
意向共享意向=新意向();
shareIntent.setAction(Intent.ACTION\u SEND\u MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA\u流,ImageURI);
setType(“image/*”);
startActivity(Intent.createChooser(shareIntent,“将图像共享给…”);

试试下面的代码,我已经在我的一个项目中多次使用了这些代码

public static void sendEmailWithMultipleAttachment(Context context,
        String caption, ArrayList<String> fileList) {
    Intent emailIntent = new Intent(
            android.content.Intent.ACTION_SEND_MULTIPLE);
    emailIntent.setType("application/octet-stream");
    emailIntent.setType("message/rfc822"); // use from live device

    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, caption);

    ArrayList<Uri> uris = new ArrayList<Uri>();

    for (String file : fileList) {
        File fileIn = new File(file);
        Uri u = Uri.fromFile(fileIn);
        uris.add(u);
    }
    emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    context.startActivity(Intent.createChooser(emailIntent,
            "Select email application."));
}
public static void sendmailwithmultipleattachment(上下文、,
字符串标题,ArrayList文件列表){
意向emailIntent=新意向(
android.content.Intent.ACTION\u SEND\u MULTIPLE);
emailIntent.setType(“应用程序/八位字节流”);
emailIntent.setType(“message/rfc822”);//从实时设备使用
emailIntent.putExtra(android.content.Intent.EXTRA_主题,标题);
ArrayList URI=新的ArrayList();
for(字符串文件:文件列表){
File fileIn=新文件(File);
uriu=Uri.fromFile(fileIn);
添加(u);
}
emailIntent.putParcelableArrayListExtra(Intent.EXTRA\u流,URI);
context.startActivity(Intent.createChooser(emailIntent,
“选择电子邮件应用程序。”);
}

这里,
ArrayList文件列表
将是图像或任何文件的路径数组。

使用android.content.Intent.ACTION\u SEND\u multipler我也尝试过。但仍然有相同的问题。你可以尝试这个答案。我已经用新代码更新了这个问题。但它仍然不起作用。当它打开Gmail应用程序时,它会显示附件,但它不起作用发送附加文件。我不知道为什么我们必须使用这样的图像路径..但它也适用于我:)我也尝试了你的代码。我已经用新代码更新了这个问题。但它仍然不起作用。当它打开Gmail应用程序时,会显示附件,但不会发送附件。@user2601652,hm。。。您没有通过arraylist中的完整路径。。这就是问题所在,我的朋友。这就是为什么我在想为什么我的代码没有运行??:)