Share multiple photos on WhatsApp

Aneh Thakur
TrinityTuts
Published in
1 min readAug 2, 2019

Hi, If you are developing an app which has lot’s of images and you want to share those image on Whatsapp together than below simple code help you to get that.

Step 1. First, you need to create a list of array image in ArrayList<Uri> then put this array into putParcelableArrayListExtra(ArrayList) when you share image.

Step 2. Here below is complete code to share an image

String message = "Sample Message";
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.setPackage("com.whatsapp");
shareIntent.putExtra(Intent.EXTRA_TEXT, message);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageLocation);
shareIntent.setType("image/jpeg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try {
startActivity(shareIntent);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(CatalogInfo.this,"Kindly install whatsapp first", Toast.LENGTH_SHORT).show();
}

If you find this post helpful then please check out some other post at TrinityTuts.com.

Thanks :)

--

--