setRotation(90) to take picture in portrait mode does not work on samsung devices

Solution 1:

I try to answer this in relation to the Exif tag. This is what I did:

Bitmap realImage = BitmapFactory.decodeStream(stream);

ExifInterface exif=new ExifInterface(getRealPathFromURI(imagePath));

Log.d("EXIF value", exif.getAttribute(ExifInterface.TAG_ORIENTATION));
if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("6")){

    realImage=ImageUtil.rotate(realImage, 90);
}else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("8")){
    realImage=ImageUtil.rotate(realImage, 270);
}else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("3")){
    realImage=ImageUtil.rotate(realImage, 180);
}

The ImageUtil.rotate():

public static Bitmap rotate(Bitmap bitmap, int degree) {
    int w = bitmap.getWidth();
    int h = bitmap.getHeight();

    Matrix mtx = new Matrix();
    mtx.postRotate(degree);

    return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true);
}

Solution 2:

Liso22, the variable stream doesn't make a difference, just plug in your bitmap, however you got it (decodeFile etc). And if you're having problems with the 'ImageUtil.rotate(), just write the 'public static Bitmap rotate()' as a method with the same parameters and make 'real image' equal that. Anyways, this solution doesn't seem to be working for me, the exif tag returns 1 (normal) whether in portrait or landscape.