Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 593
tesk_terrus Avatar asked Jul 13 '12 12:07

tesk_terrus


People also ask

How do I start my camera intent?

This is done as follows: Intent camera_intent = new Intent(MediaStore. ACTION_IMAGE_CAPTURE); startActivityForResult(camera_intent, pic_id); Now use the onActivityResult() method to get the result, here is the captured image.


1 Answers

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);
like image 121
CommonsWare Avatar answered Oct 15 '22 22:10

CommonsWare