get Orientation and up side down - Android android.view

Android examples for android.view:Surface

Description

get Orientation and up side down

Demo Code

import android.view.Surface;

public class Main {

  public static int getOrientation(int rotation, boolean upsideDown) {
    if (upsideDown) {
      switch (rotation) {
      case Surface.ROTATION_0:
        return 270;
      case Surface.ROTATION_90:
        return 180;
      case Surface.ROTATION_180:
        return 90;
      case Surface.ROTATION_270:
        return 0;
      }/*from   w  w w .  ja va 2 s. c  o m*/
    } else {
      switch (rotation) {
      case Surface.ROTATION_0:
        return 90;
      case Surface.ROTATION_90:
        return 0;
      case Surface.ROTATION_180:
        return 270;
      case Surface.ROTATION_270:
        return 180;
      }
    }

    return 0;
  }

}

Related Tutorials