任何机构都可以告诉我如何在程序设计中像我这样分享GIF图像。
其实我想分享像android share .jpg或.png图像一样的GIF图像。
我搜索了很多,但没有链接分享GIF图片,如果有人知道请告诉我。
分享GIF图片的代码? startActivity(Intent.createChooser(shareIntent,“Share Emoji”));用于分享数据时使用标题“分享表情符号”,只要我们分享jpg或png它完美地工作。但是,如果我们尝试发送GIF图像,它不能完美地工作,只有电子邮件方式有效,如果我们选择任何其他应用程序来共享GIF图像,如WhatsApp或Shareit,它将GIF图像转换为简单的png图像.....仅由此代码,我无法与其他所有应用分享GIF图像。所以请检查一下,给我合理的&如果可能的话,实际解决方案
谢谢
=============================================== ================
public class SplashScreen extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_main);
Button click = (Button) findViewById(R.id.click);
click.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
shareGif(getResources().getResourceName(R.drawable.clark));
}
});
}
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) {
}
System.out.println("===sharing file=="+sharingGifFile);
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"));
}
}