I spent a lot of hours trying to take a picture with a SurfaceView and Camera inside of a Fragment.
I have already look other solutions:
I have a working code but I have still one big issue: When I take a picture the saved image is rotated.
I have one big constraint:
- The screen orientation is only portrait.
Since I can't check my device orientation when I have android:screenOrientation="portrait"
in Manifest I can't rotate by myself the saved image.
In the other hand I know apps like snapchat achieve it so I think is not imposible. Plus If I use the following code works like a charm!
Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
mMediaUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mMediaUri);
startActivityForResult(takePhotoIntent, TAKE_PHOTO_REQUEST);
But I have to use it on a fragment, and this opens a new activity, right? Probably should I look for official android source code?
I have tried check the EXIF tag but always return 0.
I have tried using MediaStore but always return 0.
Cursor cursor = context.getContentResolver().query(photoUri,
new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null);
I think the solution is rotate the image but I'm not able get the original orientation of the image.