Camera assignment for ACTION_IMAGE_CAPTURE does not appear in Samsung Galaxy Nexus (4.0.2)

I use the following code to take a picture from the camera and get the path to the image.

...
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_IMAGE_CAPTURE); // image capture
...
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.d(TAG, "onActivityResult:" + resultCode + " request:" + requestCode);

    switch (requestCode) {
        case CAMERA_IMAGE_CAPTURE:
            Uri selectedImageUri = data.getData();
            userImagePath = getPath(selectedImageUri);
        break;
    }
}

It works great on emulator and on different devices. But on the Samsung Galaxy Nexus (4.0.2) it does not launch the camera app. But it returns RESULT_OK in onActivityResult, and I see no exceptions in LogCat. Please give me advice on how to solve this problem. Thanks in advance!

+5
source share
1 answer

You are lacking EXTRA_OUTPUT, which may affect the situation. My Galaxy Nexus can successfully run this sample project , which uses the following code to request an image:

Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);

output = new File(dir, "CameraContentDemo.jpeg");
i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(output));

startActivityForResult(i, CONTENT_REQUEST);
+7

All Articles