I am using the Java Google Drive API in Android Studio to download an image from the drive:
OutputStream outputStream = new FileOutputStream(mContext.getFilesDir() + "/" + destPath);
mDriveService.files().get(id).executeMediaAndDownloadTo(outputStream);
Most images get saved normally on the device (like the original on drive). But some images get saved rotated.
What I mean is, for example, I have a photo on google drive which is orientated in portrait mode. But after the code above downloads it on the device, the photo on the device is in landscape mode.
I found out the problem was actually not saving the image, but the way I was looking at the image (because I was displaying it in an ImageView as a Bitmap). While doing decodeFile, the image was getting rotated.
For that, the solution I used is here: Android: Bitmaps loaded from gallery are rotated in ImageView