0
我正在使用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中獲取捕獲的圖像?
你可以發佈你的整個onActivityResult? – 2015-01-09 20:23:34
Andro Selva這是完整的代碼。只是缺少啓動線。 @Override protected void onActivityResult(int requestCode,int resultCode,Intent data){ – rehmak 2015-01-10 07:03:17
然後可能會嘗試在第一行調用super.onactivityResult()。這可以幫助.. – 2015-01-12 16:49:44