我有一个带有图片查看器和共享按钮的活动,图片从数据库中检索出来。
我想先保存图片,然后再分享它。
一切都进行得很好,图像保存在内部存储器中,即将分享,但当其他应用程序运行时(如WhatsApp或Messaging),它会显示文件不受支持。
我已经手动推送其他图片到ddms,然后分享正常工作!O.o
我认为问题出在保存位图上,即使我检查了从ddms保存的位图,它看起来也很好。
这是我的代码:
save
try {
FileOutputStream out = new FileOutputStream(new File(getFilesDir(), "temp.png"));
imageview.setImageBitmap(b1);
b1.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
}
catch (Exception e) {}
共享方法
private void initShareIntent(String type,String _text)
{
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(getFilesDir(), "temp.png")));
shareIntent.setType("image/PNG");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "send"));
}