1

I have invoked the built-in Camera application in android 2.1 using intent. I've used the following code:

Intent cameraintent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), "MyTestFile.jpg");
cameraintent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
outputFileUri = Uri.fromFile(file);
startActivityForResult(cameraintent, CAMERA_PIC_REQUEST);

To get the orientation of the captured image I've used the following code:

Uri capturedImage = outputFileUri;
Bitmap theBmp = MediaStore.Images.Media.getBitmap(getContentResolver(), capturedImage);
int img_orient=0;                       
String[] projection = { MediaStore.Images.Media.ORIENTATION };
Cursor mImageCursor = managedQuery(capturedImage, projection, null, null, null);

I am not able to get the orientation of captured photo as the cursor mImageCursor is always null. What is problem in my code?

dev_android
  • 8,698
  • 22
  • 91
  • 148

1 Answers1

0

You could try using the ExifInterface class to read out the information instead. Alternatively, it's very possible that the photo has none. Some devices rotate the photos and save them without setting the orientation.

ramz
  • 986
  • 8
  • 4
  • http://stackoverflow.com/questions/3852154/android-camera-unexplainable-rotation-on-capture-for-some-devices-not-in-exif – chris-tulip Nov 22 '12 at 01:26