I hope this example can help you:
//OnActivityResult method
Uri selectedImage = data.getData();
if (selectedImage == null) {
imagePath = data.getStringExtra(GOTOConstants.IntentExtras.IMAGE_PATH);
Bitmap my_bitmap_camera = BitmapFactory.decodeFile(imagePath);
ExifInterface exif = new ExifInterface(imagePath);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
switch (orientation){
case ExifInterface.ORIENTATION_ROTATE_90:
Matrix matrix = new Matrix();
matrix.postRotate(90);
my_bitmap_camera = Bitmap.createBitmap(my_bitmap_camera, 0, 0, my_bitmap_camera.getWidth(), my_bitmap_camera.getHeight(), matrix, true);
break;
}
ivScreenshot1.setImageBitmap(my_bitmap_camera);
}
//XML
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivScreenshot1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
//Also you can check this post: How to get the Correct orientation of the image selected from the Default Image gallery