Skip to content Skip to sidebar Skip to footer

How To Share Gif Image In Whatsapp Programmatically In Android?

WhatsApp have added new feature display GIF. if any one know how to share GIF in whatsapp then let me know

Solution 1:

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

IntentshareIntent=newIntent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/gif");

Refer How to share gif image to whatsapp in android for more documentations

Solution 2:

Try this....

privatevoidshareGif(String resourceName){

    StringbaseDir= Environment.getExternalStorageDirectory().getAbsolutePath();
    StringfileName="sharingGif.gif";

    FilesharingGifFile=newFile(baseDir, fileName);

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

        FileOutputStreamfos=newFileOutputStream(sharingGifFile);
        inti= fis.read(readData);

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

        fos.close();
    } catch (IOException io) {
    }
    IntentshareIntent=newIntent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("image/gif");
    Uriuri= 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);*/

Post a Comment for "How To Share Gif Image In Whatsapp Programmatically In Android?"