0

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();
            }
Srinivas Nahak
  • 1,846
  • 4
  • 20
  • 45

1 Answers1

1

You are trying to share that URL as text. So use:

shareIntent.setType("text/plain");
Saurabh Thorat
  • 18,131
  • 5
  • 53
  • 70