I'm trying to implement a share that will send a dynamic link, a title and an image. As a start I want it to work with WhatsApp. I implemented the share intent as per the documentation:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, dynamicLink);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Title");
// If item has images, pick the first one as thumbnail
if(!item.getImagesBitmaps().isEmpty()){
Uri imageUri = ...(Getting image uri)
sendIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
sendIntent.setType("image/jpg");
}
sendIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Intent shareIntent = Intent.createChooser(sendIntent, null);
startActivity(shareIntent);
This code works. I can send the link to WhatsApp with the image and it looks as a standard image-message:
However my goal is to have a link with a thumbnail, like this:
Meaning something with a clickable thumbnail and this sort of header with title and description.
I searched quite a lot for an answer on how it can be done, and while there are similar questions here with answers they seem either old, incomplete or something that I couldn't understand how to fit with the shareIntent implementation. I couldn't extract anything tangible from them that I could try.
Appreciate the help.


If you are trying to get image from server URL then you have to load the image with Glide first(add the Glide dependency), then send the bitmap.
activity_main.xml
MainActivity.kt:
Create a folder named xml in res directory and put this file in that folder.
file_paths.xml
AndroidManifest.xml