【发布时间】:2014-02-13 11:51:53
【问题描述】:
我有图像查看和分享按钮的活动, 从数据库中检索到的图像
我想先保存图片再分享
一切正常,图像保存在内存中,它会分享,但是当其他应用程序运行(如whatsapp或消息传递)时,它说文件不支持
我已经手动将其他图像推送到 ddms,然后共享没有任何问题!哎哟
我认为问题出在保存位图上,即使我从 ddms 检查了保存的位图,它看起来不错
有我的代码:
保存
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"));
}
【问题讨论】:
-
你是如何获取位图的?