When I take a picture with Android's camera app, it detects the phone's orientation and saves the picture accordingly. So if I take a picture of a building, the roof will be on the topside, whether I hold the phone in landscape position or portrait.
However, when I use
Intent imageCaptureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
to get a picture, the camera app doesn't react to the orientation. If I hold the phone vertically (portrait), the resulting picture will be rotated, with said building's roof to the left of the screen.
How can I set the intent so that the camera will take the orientation into account?
Or can I deduce in some way in what orientation the picture was taken and rotate it myself afterwards?
Or is there another way?