-1

WhatsApp have added new feature display GIF.

if any one know how to share GIF in whatsapp then let me know

Rahul Khurana
  • 8,577
  • 7
  • 33
  • 60
Ani kukadiya
  • 174
  • 1
  • 10
  • 5
    If you have tried anything yourself, please let us know! – 0xDEADC0DE Sep 23 '16 at 08:55
  • 1
    check this http://stackoverflow.com/questions/12952865/how-to-share-text-to-whatsapp-from-my-app – Moudiz Sep 23 '16 at 08:56
  • thanks for replay I already share GIF image in all social media but now whatsapp have new feature to display GIF with animation so now share GIF in whatsapp with animation can you please help me if you know any about new whatsapp GIF feature – Ani kukadiya Sep 23 '16 at 10:58
  • 1
    I have posted a similar question related to this problem...but i want to use whatsapp mp4 format that this app show as gif inside chats UI: https://stackoverflow.com/questions/44893316/whatsapp-video-as-gif-sharing-on-android-programatically – Razec Luar Jul 04 '17 at 13:35
  • I upvoted because this is a helpful question and obviously it has generated a good amount of views. – daspianist Dec 06 '18 at 13:16

2 Answers2

1

Try this....

private void shareGif(String resourceName){

    String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
    String fileName = "sharingGif.gif";

    File sharingGifFile = new File(baseDir, fileName);

    try {
        byte[] readData = new byte[1024*500];
        InputStream fis = getResources().openRawResource(getResources().getIdentifier(resourceName, "drawable", getPackageName()));

        FileOutputStream fos = new FileOutputStream(sharingGifFile);
        int i = fis.read(readData);

        while (i != -1) {
            fos.write(readData, 0, i);
            i = fis.read(readData);
        }

        fos.close();
    } catch (IOException io) {
    }
    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 Emoji"));
}

For share gif on whatsapp

/*  Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setPackage("com.whatsapp");
shareIntent.putExtra(Intent.EXTRA_TEXT,title + "\n\nLink : " + link );
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(sharePath));
shareIntent.setType("image/*");
startActivity(shareIntent);*/
Anand Savjani
  • 2,484
  • 3
  • 26
  • 39
Preetika Kaur
  • 1,991
  • 2
  • 16
  • 23
1

You just need to set the type of image intent as gif like below

Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/gif");
Ryan M
  • 18,333
  • 31
  • 67
  • 74
Ramees
  • 68
  • 4
  • 16