0

I want to share image from my app to Whatsapp but it's giving me the error "sharing failed , please try again" this is my code:

String text = "Look at my awesome picture";
        Uri pictureUri = Uri.parse("file://www.punjabidharti.com/wp-content/uploads/2018/05/baap-600x600.jpg");
        Intent shareIntent = new Intent();
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_TEXT, text);
        shareIntent.putExtra(Intent.EXTRA_STREAM, pictureUri);
        shareIntent.setType("image/*");
        shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(Intent.createChooser(shareIntent, "Share images..."));

and I am using image url from my website.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Chand Ninder
  • 161
  • 5
  • 19

1 Answers1

0

You are passing a http url not a file url. Make your uri like this and it will work

Uri pictureUri = Uri.parse("http://www.punjabidharti.com/wp-content/uploads/2018/05/baap-600x600.jpg");
Suhaib Roomy
  • 2,501
  • 1
  • 16
  • 22