0
我试图挖掘的形象图,并打开默认照片查看器中的形象:Android设备上查看图像意图不显示图像
void handleOpenImage(){
try {
File temp = File.createTempFile("myImage", ".png");
BitmapDrawable bitmapDrawable = (BitmapDrawable) attachedImageView.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
FileOutputStream stream = new FileOutputStream(temp);
boolean success = bitmap.compress(Bitmap.CompressFormat.PNG, 0, stream);
if(!success){
throw new Exception();
}
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(temp), "image/*");
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
然而,当我调用该函数,画廊活动开始,但不显示我的图像。图像文件在临时路径中成功创建,并且双击检查。为什么不是这个意图工作?
代替startActivity(意向)使用这一个,检查它是否在我其他应用程序开放, startActivity(Intent.createChooser(意向,“选择图片”)); – Vickyexpert
@Vickyexpert哦抱歉刚刚得到你的意思。忽略我以前的评论。会尝试。 –
@Vickyexpert尝试了它,我得到了同样的结果:我选择图库,它会打开,但图片不显示。我剩下一个空的画廊活动 –