I also had the same issue in my application. Below solution worked fine for me, hope it will help you too.
Add following code in your OnActivityResult
method,
Bitmap imgTemp = null;
String path = mImageCaptureUri.getPath();
if(imgTemp != null && !imgTemp.isRecycled())
{
imgTemp.recycle();
imgTemp = null;
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = false;
options.inPurgeable = true;
options.inInputShareable = true;
options.inTempStorage = new byte[10*1024];
imgTemp = BitmapFactory.decodeFile(path,options);
imgTemp = Bitmap.createScaledBitmap(imgTemp, 480, 800, true);
ExifInterface ei = new ExifInterface(path);
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
imgTemp = rotateImage(imgTemp, 90);
break;
case ExifInterface.ORIENTATION_ROTATE_180:
imgTemp = rotateImage(imgTemp, 180);
break;
// etc.
}
Here, mImageCaptureUri is the Uri for the image captured by camera.
And also add method rotateImage
in your activity,
public Bitmap rotateImage(Bitmap source, float angle)
{
Matrix matrix = new Matrix();
matrix.postRotate(angle);
return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
}