i am writing a standart app which takes photo and then save it to the phone , as soon as i hit the save button, it saves the image, but crashes with Force Close , i read at least 10-15 threads here for the same issue, but none of them helped.I am testing on Samsung Galaxy S
here is the intent
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);
also the 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);
}
}
thanks in advance
here is the 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