Reputation: 1224
I'm trying to share some text and image via the Twitter app. The image source is a web url. Below is my code:
sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I am reading this publication, check it out here: "+bookmark_url+"");
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("http://example.com/images/thumbs/file_name.jpg"));
But only the text is getting shared via the Twitter app. I also get a message saying "Image could not be loaded". What is the problem with this code?
Upvotes: 7
Views: 7091
Reputation:
Sourav, I think you must download the picture before sharing it. You can do it manually, or maybe you could use a library like this. You can find inside the library's repository easy documentation about how to set up and use it.
After you have downloaded the picture you can follow this method:
private Intent shareIntent(String bookmark_url, String imagePath){
sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I am reading this publication, check it out here: "+bookmark_url);
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
return sharingIntent;
}
If you simply want to simulate "Parsing image on the fly", delete it after sharing.
Hope this helps you!
Upvotes: 7