Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
300 views
in Technique[技术] by (71.8m points)

android - Share image and text through whatsapp

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; 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Whatsapp Support Image sharing along with text.

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT,title + "

Link : " + 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...