title: EXIF orientation is always default value
body: <p>I know this has been discussed plenty of times before, and I have looked at many questions and many answers, and I have tried them to no avail, either because of my lack of understanding or my device. Plus, most of the questions are dated by now. I have the classic problem of portrait images coming out rotated to landscape.</p>
  
  <p>Anyways, I have a custom camera that I am using. Here is a function in my main activity:</p>
  
  <pre><code>public static int getImageOrientation(String imagePath){
       int orientation = -1;
          try {
              ExifInterface exif = new ExifInterface(imagePath);
              int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 
                      ExifInterface.ORIENTATION_NORMAL);
  
              switch (exifOrientation) {
                  case ExifInterface.ORIENTATION_ROTATE_270:
                      orientation = 270;
  
                      break;
                  case ExifInterface.ORIENTATION_ROTATE_180:
                      orientation = 180;
  
                      break;
                  case ExifInterface.ORIENTATION_ROTATE_90:
                      orientation = 90;
  
                      break;
  
                  case ExifInterface.ORIENTATION_NORMAL:
                      orientation = 0;
  
                      break;
                  default:
                      break;
              }
          } catch (IOException e) {
              Log.e("LOG_TAG", "Unable to get image exif orientation", e);
          }
  
          return orientation;
   }
  </code></pre>
  
  <p>This function is called here in my onactivityresult:</p>
  
  <pre><code>    String abspath = data.getExtras().getString(EXTRA_IMAGE_PATH);
      mMediaUri = Uri.fromFile(new File(abspath));
      rotation = getImageOrientation(abspath);
  </code></pre>
  
  <p>Now, what I am trying to do is, I'm storing the rotation in my backend so that when the image appears in a listview, it will know whether or not to be rotated. The problem is that -1 keeps being returned. What could I be doing wrong? I merely want to know if the photo was taken in portrait or landscape.</p>