So I came across this question on StackOverflow asking how one can share an image on WhatsApp along with a caption. Before the question could be answered, two users incorrectly marked it as a duplicate.

So I thought of sharing my answer here so that it can help out others.

We start by creating an ACTION_SEND Intent since the Intent sends data

Intent intent = new Intent();

We set the Intent type to image since we are primarily sending an image


The main part comes now. We need to specify in our Intent that it is meant for WhatsApp only. We can do this by specifying the package name through the setPackage() method


Now we need to specify the image and message to be shared. We specify an URI to the required image.

intent.putExtra(Intent.EXTRA_TEXT, your_message);

And finally, fire up the Intent.

try {
} catch (android.content.ActivityNotFoundException e) {
  Log.d("TAG", "WhatsApp has not been installed");

We use a try catch block to handle cases where WhatsApp is not available on the device.