How can I get the current screen orientation?
int orientation = this.getResources().getConfiguration().orientation;if (orientation == Configuration.ORIENTATION_PORTRAIT) { // code for portrait mode} else { // code for landscape mode}
When the superclass of this
is Context
int rotation = getWindowManager().getDefaultDisplay().getRotation();
this will gives all orientation like normal and reverse
and handle it like
int angle = 0;switch (rotation) { case Surface.ROTATION_90: angle = -90; break; case Surface.ROTATION_180: angle = 180; break; case Surface.ROTATION_270: angle = 90; break; default: angle = 0; break;}