5

I use the following code to share an image and text through WhatsApp. It only shares the image, not the text, however. I have searched all over the Internet, but haven't found a solution.

 String message = Fname + Mobileno + Homeno + Workmail + Homemail
                + Gtalk + Skype + Address + Company + Title + Website;
      Intent shareIntent = new Intent(Intent.ACTION_SEND); 
      Uri uri = Uri.parse("file://"
                + Environment.getExternalStorageDirectory()
                + "/Talk&Share/Images/profpic.png");

      shareIntent.putExtra(Intent.EXTRA_TEXT, message); 
      shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Contact"); 
      if(uri != null){
       shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
       shareIntent.setType("image/plain");
      }else{
       shareIntent.setType("plain/text");
      }

         return shareIntent; 
TofferJ
  • 4,678
  • 1
  • 37
  • 49
Basim Sherif
  • 5,384
  • 7
  • 48
  • 90

4 Answers4

10

Whatsapp Support Image sharing along with text.

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT,title + "\n\nLink : " + link );
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imageFilePath));
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share image via:"));

This will share image and EXTRA_TEXT will consider as image caption.

Shabbir Dhangot
  • 8,954
  • 10
  • 58
  • 80
8

Use:

Intent.ACTION_SEND_MULTIPLE

instead of:

Intent.ACTION_SEND
Rizier123
  • 58,877
  • 16
  • 101
  • 156
M.Prabha karan
  • 697
  • 6
  • 17
3

This is not possible, as WhatsApp does not support messages with both pictures and text in them. A message may consist of a single image, text sequence, audio file, contact or video. You cannot have a combination of any of those.

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
-1
Intent i = new Intent(android.content.Intent.ACTION_SEND);
 i.setType("text/plain");
 i.putExtra(Intent.EXTRA_SUBJECT, "Subject");
 i.putExtra(Intent.EXTRA_TEXT, "Message body");
startActivity(Intent.createChooser(i, "Share dialog title"));
Furqi
  • 2,403
  • 1
  • 26
  • 32