【发布时间】:2014-12-24 01:11:26
【问题描述】:
我正在尝试显示从相机意图捕获的图像,但是当我调用 showPhoto 方法时,图像未显示在 ImageView 中。堆栈跟踪没有错误输出,所以我不确定如何调试问题。
有人知道不显示捕获图像的方法有什么问题吗?
showPhoto方法如下:
private void showPhoto(Uri photoUri) {
String filePath = photoUri.getEncodedPath();
File imageFile = new File(filePath);
//File imageFile = new File(photoUri.getPath());
if (imageFile.exists()){
Drawable oldDrawable = photoImage.getDrawable();
if (oldDrawable != null) {
((BitmapDrawable)oldDrawable).getBitmap().recycle();
}
Bitmap bitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
BitmapDrawable drawable = new BitmapDrawable(this.getResources(), bitmap);
photoImage.setScaleType(ImageView.ScaleType.FIT_CENTER);
photoImage.setImageDrawable(drawable);
}
}
这是我遵循的教程:http://www.linux.com/learn/tutorials/722038-android-calling-the-camera
我正在测试的设备是JellyBean 4.1,这是完整课程的链接:
【问题讨论】:
-
可能是图片质量问题。尝试降低位图的质量。
标签: java android imageview android-camera-intent