Reputation: 1876
Actually I've given a share option in my app to share pictures to whatsapp
by referring this link but it' not working . It's toasting something like Share failded please try again
.Can anyone please help me to solve this issue.
Code:
String image_url = "http://images.cartradeexchange.com//img//800//vehicle//Honda_Brio_562672_5995_6_1438153637072.jpg";
Intent shareIntent = new Intent();
shareIntent.setType("image/*");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, image_url);
// Target whatsapp:
shareIntent.setPackage("com.whatsapp");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try {
startActivity(shareIntent);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(InventoryManageOnlineActivity.this,
"Whatsapp have not been installed.",
Toast.LENGTH_SHORT).show();
}
Upvotes: 0
Views: 90
Reputation: 20734
You are trying to share that URL as text. So use:
shareIntent.setType("text/plain");
Upvotes: 1