我正在使用ACTION_IMAGE_CAPTURE从使用Intent的相机捕获图像。 我正在使用此代码:
Intent i = new Intent (MediaStore.ACTION_IMAGE_CAPTURE);
//startActivity(i);
startActivityForResult(i,1);
通过此代码获取意图结果:
InputStream stream = null;
if (requestCode == 1 && resultCode == Activity.RESULT_OK)
try
{
// recyle unused bitmaps
if (bitmap != null) {
bitmap.recycle();
}
stream = getContentResolver().openInputStream(data.getData());
bitmap = BitmapFactory.decodeStream(stream);
imgPic.setImageBitmap(bitmap);
} catch (FileNotFoundException e)
{
//e.printStackTrace();
Log.e("ERROR 2 :->",e.toString());
}
if (stream != null)
{
try
{
stream.close();
} catch (IOException e)
{
//e.printStackTrace();
Log.e("ERROR 3 :->",e.toString());
}
}
}
但是当我点击图片预览意图中的勾选按钮时,它会给我这个错误:
1-10 00:55:34.675 25036-25036/com.digicare.digitrick W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x40e3d258)
01-10 00:55:34.686 25036-25036/com.digicare.digitrick E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data (has extras) }} to activity
我在哪里缺少一些东西???? 如何在ImageView中获取捕获的图像?