0

enter image description here

I need to share the content to whatsapp as Instagram does in picture attached.

The title section has an thumbnail of the image and title text and link. Then Message section has a link.

The Message section is straight forward. Any help on implementing the title section will be helpful.

Intent sendIntent = new Intent();   
sendIntent.setAction(Intent.ACTION_SEND);   
sendIntent.putExtra(Intent.EXTRA_TITLE, "title text");   
sendIntent.putExtra(Intent.EXTRA_TEXT, "message section");   
sendIntent.setType("text/plain"); 
startActivity(sendIntent);

I have gone through whatsapp faq but they haven't mentioned list of the labels processed from the intent.

https://faq.whatsapp.com/en/android/28000012

Sowmia Sundararajan
  • 1,613
  • 2
  • 14
  • 17

1 Answers1

0

Try below code

Uri imgUri = Uri.parse(pictureFile.getAbsolutePath());
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.setPackage("com.whatsapp");
    intent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
    intent.putExtra(Intent.EXTRA_STREAM, imgUri);
    intent.setType("image/jpeg");
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    try {
        activity.startActivity(intent);
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.MakeText(this,"Whatsapp not found",Toast.LENGTH_SHORT).show();
    }
Satyajit
  • 625
  • 7
  • 12