3

i am new to share intent concept ,i want to share image and text from my app to other apps like whatsapp etc.., i tryed this but one text content was sharing ,my requirement is when i share text and image ,it will display in whats app along with image please any one help me how to got this

here below my code

Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(Intent.EXTRA_TEXT,decsription_text.getText().toString()+imagelink);

            shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Write the title what ever you want");
            startActivity(Intent.createChooser(shareIntent, "Share Via..."));

my images getting from server here image url

Picasso.with(getApplicationContext()).load((News_Updates.listData.get(pos)).getNewsImage()).into(Imageviewsample);
chanti
  • 601
  • 2
  • 8
  • 17

1 Answers1

2

Try below code

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_TEXT,
        "Here is my IMAGE");
startActivity(Intent.createChooser(shareIntent, "Share IMAGE Using..."));

Here I am attaching an image and text. I am sending the image as a stream. You can save the image temporarily and send the URI of the file as extra with the intent.

Mobile Developer
  • 231
  • 2
  • 15
Balu SKT
  • 549
  • 5
  • 22