2016-09-23 79 views
-2

WhatsApp已添加新功能显示GIF。如何在Android中以编程方式在WhatsApp中共享GIF图像?

,如果任何一个懂得分享GIF在WhatsApp的然后让我知道

+4

如果你自己已经尝试了什么,请告诉我们! – 0xDEADC0DE

+1

检查这个http://stackoverflow.com/questions/12952865/how-to-share-text-to-whatsapp-from-my-app – Moudiz

+0

感谢重播 我已经在所有的社交媒体分享GIF图像,但现在whatsapp有新的功能,以动画 显示GIF 所以现在分享GIF的动画可以请你帮我WhatsApp的,如果你知道任何有关新的WhatsApp GIF功能 –

回答

0

试试这个....

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")); 
} 

对于分享GIF上的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);*/ 
+0

感谢的答案,但使用这种分享GIF方法GIF不动画只是显示图像。我正在讨论新的WhatsApp功能 –

+0

setType(“image/gif”);替代型和尝试请 –

+0

我使用的setType(“图像/ GIF”),但不GIF动画也尝试仍然显示简单的图片 –

相关问题