0

How can I attach multiple images to mail Composer.

 final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
 emailIntent.setType("*/*");
 ArrayList<Uri> uris = new ArrayList<Uri>();
            for (int i = 1; i < alBitmap.size(); i++) {
                strFile = strFile + "/" + i + ".jpg";
                File fileIn = new File(strFile);
                Uri u = Uri.fromFile(fileIn);
                uris.add(u);
            }
 emailIntent.putExtra(Intent.EXTRA_STREAM, uris);
 emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "");
 this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));

But, It gives following error :

java.lang.ClassCastException: java.util.ArrayList cannot be cast to android.os.Parcelable.

Can anybody tell me whats the Solution ? I have also used putArrayListExtra instead of putExtra.

user5716019
  • 598
  • 4
  • 17

2 Answers2

0

Use ACTION_SEND_MULTIPLE. Or, better yet, a builder that will create share Intents for you:

cketti
  • 1,277
  • 11
  • 15
0

Not sure if you ever got your problem fixed, but you're close. Change emailIntent.putExtra to emailIntent.putParcelableArralyListExtra and leave everything else the same.

Cody Harness
  • 1,116
  • 3
  • 18
  • 37