Share Multiple Images in WhatsApp using Android Intent


You can share multiple images to WhatsApp contacts using Intents by using putParcelableArrayListExtra method and passing an image URI ArrayList object.

Code Snippet:
    Uri uri1 = Uri.parse("android.resource://com.code2care.example.whatsappintegrationexample/drawable/image1");
    Uri uri2 = Uri.parse("android.resource://com.code2care.example.whatsappintegrationexample/drawable/image2");
    Uri uri3 = Uri.parse("android.resource://com.code2care.example.whatsappintegrationexample/drawable/image3");
        
    ArrayList<Uri> imageUriArray = new ArrayList<Uri>();
    imageUriArray.add(uri1); 
    imageUriArray.add(uri2);
        
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, "Text caption message!!");
    intent.setType("text/plain");
    intent.setType("image/jpeg");
    intent.setPackage("com.whatsapp");
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUriArray);
    startActivity(intent);

You would see multiple images stack when the Android WhatsApp Activity page is loaded and you select a contact or group!!

Share Multiple Images with WhatsApp Android Intent
Share Multiple Images with WhatsApp Android Intent

Comments:

  • Worked like a charm! Thank you!
    anon 08 Nov 2020 17:11:43 GMT
  • Further comments disabled!





Recent Posts:
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.