我想与whatsapp等可用的应用程序共享.gif,但无法在我的drawable资源中获得有效的Uri gri.
Uri path = Uri.parse("android.resource://my_package_name/" + R.drawable.gif_1);
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/gif");
shareIntent.putExtra(Intent.EXTRA_STREAM, path);
Run Code Online (Sandbox Code Playgroud)
有很多关于共享图像的解决方案,但没有关于gif共享的解决方案,请帮忙
作为
bm.compress(Bitmap.CompressFormat.PNG, 50, out);
//here 50 will not work as PNG is lossless
如何减小 .png 图像大小?也只是从 drawable 处理外部位置使文件大小增加 5 到 10 倍?
Bitmap bm=BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
File file = new File(extStorageDirectory, "ic_launcher.PNG");
outStream = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
Run Code Online (Sandbox Code Playgroud)