I have an Android app screen which shows an image, a description and other additional information. I'd like to share this via social media (like Facebook, Twitter, etc). Basically I'd like to send the image, a small text and a URL. I have added a Share button and used this code:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
Uri uriToImage = Uri.parse("http://remote.path.to.image.jpg");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Learn more about this");
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.setType("*/*");
startActivity(Intent.createChooser(shareIntent, "Share"));
However this does not work. I have tested it with Facebook and while it shows the sheet and lets me choose Facebook, I'm presented with an empty message; the text and image are not attached. If I try with GMail it only attaches the text and mentions that the image could not be attached.
Also how can I include the URL that I want to share?
I'm working with Java.
In Your manifest file add this line
Add this line inside appliction tag
In your java file ask runtime permission for storage