0
我正在寫一個非標準的應用程序,它會拍照並將其保存到手機中,一旦我點擊保存按鈕,它就會保存圖像,但是用力關閉時崩潰,至少我讀了10-15螺紋這裏同樣的問題,但他們沒有helped.I我對三星Galaxy測試小號保存照片後Android不斷崩潰
這裏是意圖
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
imageFilePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/picture.jpg";
File imageFile = new File(imageFilePath);
Uri imageFileUri = Uri.fromFile(imageFile);
cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,imageFileUri);
startActivityForResult(cameraIntent, 1337);
也OnActivity
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK)
{
BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inJustDecodeBounds = false;
Bitmap bmp = BitmapFactory.decodeFile(imageFilePath, bmpFactoryOptions);
image.setImageBitmap(bmp);
}
}
感謝ADVA NCE
這裏是logcat的
06-21 13:07:09.421: D/AndroidRuntime(18525): Shutting down VM 06-21 13:07:09.421: W/dalvikvm(18525): threadid=1: thread exiting with uncaught exception (group=0x40018578) 06-21 13:07:09.421: E/AndroidRuntime(18525): FATAL EXCEPTION: main 06-21 13:07:09.421: E/AndroidRuntime(18525): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1337, result=-1, data=null} to activity {com.example.testnewbutton/com.example.testnewbutton.MainActivity}: java.lang.NullPointerException 06-21 13:07:09.421: E/AndroidRuntime(18525): at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) 06-21 13:07:09.421: E/AndroidRuntime(18525): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578) 06-21 13:07:09.421: E/AndroidRuntime(18525): at android.app.ActivityThread.access$2000(ActivityThread.java:117) 06-21 13:07:09.421: E/AndroidRuntime(18525): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965) 06-21 13:07:09.421: E/AndroidRuntime(18525): at android.os.Handler.dispatchMessage(Handler.java:99) 06-21 13:07:09.421: E/AndroidRuntime(18525): at android.os.Looper.loop(Looper.java:130) 06-21 13:07:09.421: E/AndroidRuntime(18525): at android.app.ActivityThread.main(ActivityThread.java:3687) 06-21 13:07:09.421: E/AndroidRuntime(18525): at java.lang.reflect.Method.invokeNative(Native Method) 06-21 13:07:09.421: E/AndroidRuntime(18525): at java.lang.reflect.Method.invoke(Method.java:507) 06-21 13:07:09.421: E/AndroidRuntime(18525): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 06-21 13:07:09.421: E/AndroidRuntime(18525): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 06-21 13:07:09.421: E/AndroidRuntime(18525): at dalvik.system.NativeStart.main(Native Method) 06-21 13:07:09.421: E/AndroidRuntime(18525): Caused by: java.lang.NullPointerException
請寄出LogCat。 – BackSlash
06-21 13:07:09.421 E/AndroidRuntime(18525):致命異常:主 06-21 13:07:09.421:E/AndroidRuntime(18525):java.lang.RuntimeException:失敗,提供結果ResultInfo {who = null,request = 1337,result = -1,data = null} to activity {com.example.testnewbutton/com.example.testnewbutton.MainActivity}:java.lang.NullPointerException –
http://stackoverflow.com/questions/ 3275749/IM-得到-A-NullPointerException異常-時,我使用的動作,圖像採集到採取-A-PIC – Dimmerg