zerocool99 February 2016

Android camera error Failure delivering result ResultInfo

I'm trying to get my camera to work for my android app but i keep getting the following error

02-07 22:30:48.217 13197-13197/com.example.romsm.lap E/AndroidRuntime: FATAL EXCEPTION: main java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data dat=content://media/external/images/media/8557 (has extras) }} to activity {com.example.romsm.lap/com.example.romsm.lap.TreeQuestionsActivity}: java.lang.NullPointerException at at at$1200( at$H.handleMessage( at android.os.Handler.dispatchMessage( at android.os.Looper.loop( at at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke( at


John Joe February 2016

This is my code to make the camera works. You may try this.

 private void activeTakePhoto() {
        Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);

    protected void onActivityResult(int requestCode, int resultCode,
                                    Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case REQUEST_IMAGE_CAPTURE:
                if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK & null != data) {

                Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
                ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                thumbnail.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
                //to generate random file name
                String fileName = "tempimg.jpg";

                try {
                    photo = (Bitmap) data.getExtras().get("data");
                    //captured image set in imageview
                } catch (Exception e) {

Post Status

Asked in February 2016
Viewed 2,367 times
Voted 12
Answered 1 times


Leave an answer