Skip to content Skip to sidebar Skip to footer

How To Send The Image Captured By Intent By Whatsapp

In my android app I have activity where when user clicks a button it opens camera by using intent, takes a photo, shows it as a image view in the same activity and after that there

Solution 1:

I think this Link help you for better understanding How to send Images to whatsupp by using Intent.

I Hope you doing well

Solution 2:

Below code will give a generic way of sharing image and text to whats app and other similar apps.

publicvoidshareShop(Activity activity, String imagePath, String url) {
        Intent whatsappIntent = newIntent(android.content.Intent.ACTION_SEND);
        whatsappIntent.putExtra(Intent.EXTRA_TEXT, url);
        if (imagePath != null) {
            whatsappIntent.setType("image/*");
            whatsappIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + imagePath));
        }//add image pathelse {
            whatsappIntent.setType("text/*");
        }
        activity.startActivity(Intent.createChooser(whatsappIntent, "Share image using"));
        try {
            activity.startActivity(whatsappIntent);
        } catch (android.content.ActivityNotFoundException ex) {
            Toast.makeText(activity, "Whatsapp have not been installed.", Toast.LENGTH_SHORT).show();
        }
    }

Solution 3:

Try this:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.setPackage(“com.whatsapp");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ imagePath));

Solution 4:

String imagePath = "file://" + image.getAbsolutePath();Uri.parse(imagePath)

Solution 5:

I use this :

whatsapp.setOnClickListener(newView.OnClickListener() {
                @OverridepublicvoidonClick(View view) {

                    File f=newFile(muxedvdo);
                    Uriuri= Uri.parse("file://"+f.getAbsolutePath());
                    Intentshare=newIntent(Intent.ACTION_SEND);
                    share.setPackage("com.whatsapp");
                    share.putExtra(Intent.EXTRA_STREAM, uri);
                    share.setType("image/jpeg");
                    share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    startActivity(Intent.createChooser(share, "Share imageFile"));

                }
            });

Post a Comment for "How To Send The Image Captured By Intent By Whatsapp"