0
我試圖用相機拍攝照片並在其後裁剪。因爲這是使用此代碼:從相機拍攝照片並剪裁它
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == PICK_FROM_CAMERA && resultCode == Activity.RESULT_OK)
{
Bundle extras = data.getExtras();
if (extras != null)
{
Bitmap photo = extras.getParcelable("data");
//iv.setImageBitmap(photo);
}
}
}
public void ImageClicked(View v)
{
// call android default camera
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, PICK_FROM_CAMERA);
// ******** code for crop image
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 0);
intent.putExtra("aspectY", 0);
intent.putExtra("outputX", 200);
intent.putExtra("outputY", 150);
try
{
intent.putExtra("return-data", true);
startActivityForResult(intent, PICK_FROM_CAMERA);
}
catch (ActivityNotFoundException e)
{
// Do nothing for now
}
}
我可以拍攝照片完美,但在那之後我的應用程序崩潰,出現此錯誤:「不幸的是畫廊已停止」。我的清單看起來是這樣的:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
這是從我的錯誤的目錄下載:
05-18 01:55:00.580: E/caladbolg(180): 3118424938 cald_hal_qct.c (15716) 25052 E [HCF] Not found unlocked buffer.
05-18 01:55:00.620: E/caladbolg(180): 3118460460 cald_hal_qct.c (15716) 25052 E [HCF] Not found unlocked buffer.
05-18 01:55:00.650: E/caladbolg(180): 3118491924 cald_hal_qct.c (15716) 25052 E [HCF] Not found unlocked buffer.
05-18 01:55:00.680: E/caladbolg(180): 3118525585 cald_hal_qct.c (15716) 25052 E [HCF] Not found unlocked buffer.
05-18 01:55:00.720: E/caladbolg(180): 3118559429 cald_hal_qct.c (15716) 25052 E [HCF] Not found unlocked buffer.
05-18 01:55:00.750: E/caladbolg(180): 3118592937 cald_hal_qct.c (15716) 25052 E [HCF] Not found unlocked buffer.
05-18 01:55:00.783: E/caladbolg(180): 3118626598 cald_hal_qct.c (15716) 25052 E [HCF] Not found unlocked buffer.
05-18 01:55:00.820: E/caladbolg(180): 3118660320 cald_hal_qct.c (15716) 25052 E [HCF] Not found unlocked buffer.
05-18 01:55:00.850: E/caladbolg(180): 3118694469 cald_hal_qct.c (15716) 25052 E [HCF] Not found unlocked buffer.
05-18 01:55:00.890: E/caladbolg(180): 3118727642 cald_hal_qct.c (15716) 25052 E [HCF] Not found unlocked buffer.
05-18 01:55:10.950: E/AudioHardware7x30(180): updateDeviceInfo: E rx_device 2 and tx_device 3
05-18 01:55:10.950: E/AudioHardware7x30(180): updateDeviceInfo: X cur_rx 2 cur_tx 3
05-18 01:55:11.630: E/AndroidRuntime(24928): FATAL EXCEPTION: main
05-18 01:55:11.630: E/AndroidRuntime(24928): java.lang.IllegalStateException: Could not execute method of the activity
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.view.View$1.onClick(View.java:3591)
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.view.View.performClick(View.java:4084)
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.view.View$PerformClick.run(View.java:16966)
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.os.Handler.handleCallback(Handler.java:615)
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.os.Handler.dispatchMessage(Handler.java:92)
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.os.Looper.loop(Looper.java:137)
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.app.ActivityThread.main(ActivityThread.java:4931)
05-18 01:55:11.630: E/AndroidRuntime(24928): at java.lang.reflect.Method.invokeNative(Native Method)
05-18 01:55:11.630: E/AndroidRuntime(24928): at java.lang.reflect.Method.invoke(Method.java:511)
05-18 01:55:11.630: E/AndroidRuntime(24928): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
05-18 01:55:11.630: E/AndroidRuntime(24928): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
05-18 01:55:11.630: E/AndroidRuntime(24928): at dalvik.system.NativeStart.main(Native Method)
05-18 01:55:11.630: E/AndroidRuntime(24928): Caused by: java.lang.reflect.InvocationTargetException
05-18 01:55:11.630: E/AndroidRuntime(24928): at java.lang.reflect.Method.invokeNative(Native Method)
05-18 01:55:11.630: E/AndroidRuntime(24928): at java.lang.reflect.Method.invoke(Method.java:511)
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.view.View$1.onClick(View.java:3586)
05-18 01:55:11.630: E/AndroidRuntime(24928): ... 11 more
05-18 01:55:11.630: E/AndroidRuntime(24928): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.camera.action.CROP dat=file:///data/data/com.android.gallery3d/files/crop-temp (has extras) }
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.app.Activity.startActivityForResult(Activity.java:3351)
05-18 01:55:11.630: E/AndroidRuntime(24928): at android.app.Activity.startActivityForResult(Activity.java:3312)
05-18 01:55:11.630: E/AndroidRuntime(24928): at com.android.camera.Camera.doAttach(Camera.java:1442)
05-18 01:55:11.630: E/AndroidRuntime(24928): at com.android.camera.Camera.onReviewDoneClicked(Camera.java:1362)
05-18 01:55:11.630: E/AndroidRuntime(24928): ... 14 more
05-18 01:55:29.900: E/RadioFeedRequest(24881): Invalid value for content filter: 1
哪裏是我的問題?我需要改變什麼?
好,我知道了這個教程的工作:HTTP:// stackoverflow.com/a/10776670/2047987 – Cilenco