Java 当使用Intent将动画Gif共享到Twitter时,Twitter将其设置为静态图像(Android)
当我使用Intent将动画gif分享给Twitter时,Twitter会使其成为静态图像 它可以与Facebook Messenger共享 我使用这个类来创建动画gif。 有人能帮我吗 下面是我的代码Java 当使用Intent将动画Gif共享到Twitter时,Twitter将其设置为静态图像(Android),java,android,Java,Android,当我使用Intent将动画gif分享给Twitter时,Twitter会使其成为静态图像 它可以与Facebook Messenger共享 我使用这个类来创建动画gif。 有人能帮我吗 下面是我的代码 public byte[] generateGIF(ArrayList<Bitmap> bitmaps) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); AnimatedGifEncoder enc
public byte[] generateGIF(ArrayList<Bitmap> bitmaps) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
AnimatedGifEncoder encoder = new AnimatedGifEncoder();
encoder.start(bos);
for (Bitmap bitmap : bitmaps) {
encoder.addFrame(bitmap);
}
encoder.finish();
return bos.toByteArray();
}
private void shareGif (byte[] bytes,String fileName) {
try {
File file = new File(getApplicationContext().getCacheDir(), fileName + ".gif");
FileOutputStream fOut = new FileOutputStream(file);
fOut.write(bytes);
fOut.close();
file.setReadable(true, false);
final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
intent.setType("image/gif");
startActivity(Intent.createChooser(intent , "Send image using.."));
} catch (Exception e) {
e.printStackTrace();
}
}
public byte[]generateGIF(数组列表位图){
ByteArrayOutputStream bos=新建ByteArrayOutputStream();
AnimatedGifEncoder编码器=新的AnimatedGifEncoder();
编码器启动(bos);
用于(位图:位图){
编码器。添加帧(位图);
}
编码器。完成();
返回bos.toByteArray();
}
私有void shareGif(字节[]字节,字符串文件名){
试一试{
File File=新文件(getApplicationContext().getCacheDir(),fileName+“.gif”);
FileOutputStream fOut=新的FileOutputStream(文件);
fOut.写入(字节);
fOut.close();
setReadable文件(真、假);
最终意图=新意图(android.content.Intent.ACTION\u SEND);
intent.addFlags(intent.FLAG\授予\读取\ URI\权限);
intent.setFlags(intent.FLAG\u活动\u新任务);
intent.putExtra(intent.EXTRA_流,Uri.fromFile(file));
intent.setType(“image/gif”);
startActivity(Intent.createChooser(Intent,“使用..发送图像”);
}捕获(例外e){
e、 printStackTrace();
}
}
Hi Taishi,你能同时向fb messenger共享gif和文本吗?Hi Taishi,你能同时向fb messenger共享gif和文本吗?