Android Camera Intent crashes with Nexus 5 Lollipop 5.1

589 views Asked by At

I have been running this code on other versions of android without a problem till I got a report of a crash on the Nexus with Lollipop 5.1. When I run the on the Nexus 5 with API 22 on the AVD, the app crashes as soon as the camera comes up. The code is as follows:

Intent takePictureIntent = new    
 Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
            // Error occurred while creating the File
            bPhotoStarted = false;

        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
                 takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                       Uri.fromFile(photoFile));
            mFullUri = Uri.fromFile(photoFile);
            startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
        }
    }
0

There are 0 answers