1

I am taking a photo with the phone camera (tested on samsung and on nexus 4) and then getting the image path. Weird enough, on Samsung it works, on nexus 4 it returns null. Same code..

// Get image from captured image
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
 if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
 startActivityForResult(takePictureIntent, ACTION_REQUEST_CAMERA);
}

And onActivityResult:

       case ACTION_REQUEST_CAMERA:

            if (requestCode == ACTION_REQUEST_CAMERA && resultCode == RESULT_OK) {
                photoTakenFromCamera = true;
                if (intent != null) {
                    Bundle extras = intent.getExtras();
                    Bitmap imageBitmap = (Bitmap) extras.get("data");
                    takenImg.setImageBitmap(imageBitmap);
                    targetUri = intent.getData();
                } else {
                    System.out.println("intent is null. don't know why.");
                    targetUri = takenImagePath;
                }

                if (targetUri != null) {
                    System.out.println("TargetUri path: " + targetUri.getPath());
                } else {
                    System.out.println("targetUri is null.");
                }
            }
            break;

And on nexus phone, targetUri returns null.

The minSdkVersion is 15 and targeted is 19. Does anyone see what i am missing here? Thank you.

Gabi Radu
  • 1,107
  • 2
  • 16
  • 35
  • 1
    use this link http://stackoverflow.com/questions/20424909/android-startcamera-gives-me-null-intent-and-does-it-destroy-my-global-varia –  Nov 25 '14 at 17:40

1 Answers1

0

You should use this library (https://github.com/ralfgehrer/AndroidCameraUtil). Some devices have diferent implementations...

This library is prepared to handle with that diferences

Sandro Machado
  • 9,921
  • 4
  • 36
  • 57