我正在學習graphics.Camera。和我的照相機拍攝的照片,當我設置設置一個不可變的位圖圖像給出錯誤?
所拍攝的圖像「的位圖圖像」作爲畫布中,App crashs和logcat的說「位圖
圖像是不可變的」。其實,我不知道這是什麼意思?任何建議?
在此先感謝。
代碼
OnClickListener btn01Listener = new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent CameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(CameraIntent, CAMERA_PIC_REQUEST);
}
};
保護無效onActivityResult(INT requestCode,INT發送resultCode,意圖數據){
if (requestCode == CAMERA_PIC_REQUEST && resultCode == RESULT_OK) {
image = (Bitmap) data.getExtras().get("data");
ImageView img01 = (ImageView) findViewById(R.id.img01);
//img01.setImageBitmap(image);
c = new Camera();
can = new Canvas();
can.setBitmap(Bitmap.createBitmap(image));
}
}
LogCaat:
03-23 20:46:16.188: E/AndroidRuntime(452): FATAL EXCEPTION: main
03-23 20點46分:16.188:E/AndroidRuntime(452):java.lang.RuntimeException:Unable繼續活動{com.androidbook.Camera3DDemo.Camera3DDemoActivity}:java.lang.RuntimeException:傳遞結果失敗ResultInfo {who = null,request = 0,result = -1,data = Intent {act = inline -data(has extras)}} to activity {com.androidbook.Camera3DDemo.Camera3DDemoActivity}:java.lang.IllegalStateException 03-23 20:46:16.188:E/AndroidRuntime(452):at android .app.ActivityThread.performResumeActivity(ActivityThread.java:2120) 03-23 20:46:16.188:E/AndroidRuntime(452):at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135) 03-23 20 :46:16.188:E/AndroidRuntime(452):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668) 03-23 20:46:16.188:E/AndroidRuntime(452):at android.app.ActivityThread .handleRelaunchActivity(ActivityThread.java:2832) 03-23 20:46:16.188:E/AndroidRuntime(452):at android.app.ActivityThread.access $ 1600(ActivityThread.java:117) 03-23 20:46:16.188:E/AndroidRuntime(452) at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:935) 03-23 20:46:16.188:E/AndroidRuntime(452):at android.os.Handler.dispatchMessage(Handler.java:99) 03-23 20:46:16.188:E/AndroidRuntime(452):at android.os.Looper.loop(Looper.java:130) 03-23 20:46:16.188:E/AndroidRuntime(452):at android .app.ActivityThread.main(ActivityThread.java:3683) 03-23 20:46:16.188:E/AndroidRuntime(452):at java.lang.reflect.Method.invokeNative(Native Method) 03-23 20: 46:16.188:E/AndroidRuntime(452):在java.lang.reflect.Method.invoke(Method.java:507) 03-23 20:46:16.188:E/AndroidRuntime(452):at com.android .internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839) 03-23 20:46:16.188:E/AndroidRuntime(452):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java :597) 03:20:46:16.188:E/AndroidRuntime(452):at dalvik.system.NativeStart.main(Native Method) 03-23 20:46:16.188:E/AndroidRuntime(452):Caused通過:java.lang.RuntimeException:失敗的結果ResultInfo {who = null,request = 0,result = -1,data = Intent {act = inline-data(has extras)}} to activity {com.androidbook.Camera3DDemo/com/AndroidRuntime(452):at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) 03-23 20:46:16.188:E/AndroidRuntime(452):at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2107) 03-23 20:46:16.188:E/AndroidRuntime(452):... 13更多 03-23 20:46:16.188:E/AndroidRuntime(452):引起:java.lang。IllegalStateException 03-23 20:46:16.188:E/AndroidRuntime(452):at android.graphics.Canvas.setBitmap(Canvas.java:144) 03-23 20:46:16.188:E/AndroidRuntime(452):在android.app.Activity.dispatchActivityResult(Activity.java:3908) (在Camera.Androidbook.Camera3DDemo.Camera3DDemoActivity.onActivityResult(Camera3DDemoActivity.java:43) 03-23 20:46:16.188:E/AndroidRuntime(452) 03-23 20:46:16.188:E/AndroidRuntime(452):at android.app.ActivityThread.deliverResults(ActivityThread.java:2528) 03-23 20:46:16.188:E/AndroidRuntime(452):.. 14更多
我改變了onActivityResult()方法,但仍是應用crashs – Androelpha 2012-03-23 11:38:17
你能提供的錯誤日誌? – Tim 2012-03-23 11:44:40
請檢查logcat,上面張貼 – Androelpha 2012-03-23 11:50:03