Share image and text through whatsapp
Asked Answered
D

4

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; 
Detective answered 19/3, 2013 at 10:3 Comment(1)
#26199232Anatomize
K
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.

Keilakeily answered 17/11, 2014 at 11:43 Comment(0)
L
8

Use:

Intent.ACTION_SEND_MULTIPLE

instead of:

Intent.ACTION_SEND
Lumberman answered 25/2, 2015 at 6:30 Comment(0)
K
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.

Kucik answered 20/3, 2013 at 14:33 Comment(3)
Is there any way I can detect which app is the sharer when using share action provider? So that I can use different intents.Detective
@BasimSherif Not that I am aware ofKucik
It was not supporting but now it's working #26199232Anatomize
F
-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"));
Fredel answered 19/3, 2013 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.