Camera intent for ACTION_IMAGE_CAPTURE does not appear on Samsung Galaxy Nexus(4.0.2)

tesk_terrus picture tesk_terrus · Jul 13, 2012 · Viewed 14k times · Source

I use following code take a Picture from camera and to obtain picture's path.

...
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 good on emulator and on different devices. But on Samsung Galaxy Nexus(4.0.2) it does not launches Camera app. But it returns RESULT_OK to onActivityResult and I see no exceptions in LogCat. Please give me and advice how to solve this issue. Thanks in advance!

Answer

CommonsWare picture CommonsWare · Jul 13, 2012

You are missing EXTRA_OUTPUT, which may impact matters. My Galaxy Nexus can run this sample project successfully, which uses the following code to request the picture:

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);