How to share gif image to whatsapp in android

In the latest update of WhatsApp it is allowing other applications to share gif images.  It is quite similar to normal intent image sharing method in android. In this tutorial we will learn how to share gif images to WhatsApp or to any other application which allows sharing like Gmail , facebook etc.

Following is the function which is used to share the gif images

private void ShareGif() {

// replace the path and file name with your gif image path and name
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
String fileName = "temporary_file.gif";

File sharingGifFile = new File(baseDir, fileName);

Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/gif");
Uri uri = Uri.fromFile(sharingGifFile);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "Share image"));

}

You can call the above function whenever you want to share gif by replacing the path to your gif image path in your code.

This will popup a dialog containing all apps which allows sharing, you can pick whatsapp , facebook , gmail etc based on your requirement.

About the author

Hi guys, i am the author of codesfor. I am a B.Tech graduate currently working as an App developer. Apart from job i am a blogger and a freelancer.

One Comment

  1. bns October 4, 2017 Reply

Add a Comment

Your email address will not be published. Required fields are marked *