im trying to Lock screen orientation
in android application.I used following code to lock screen orientation when specific button click fire.
// Inside button click
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
if (display.getOrientation() == 1) {
setRequestedOrientation(0);
} else if (display.getOrientation() == 0) {
setRequestedOrientation(1);
} else if (display.getOrientation() == 3) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
}
Above code working for both landscape and portrait screen orientations but its not working for reverse landscape mode.In that case always my activity change it's orientation
to default landscape
mode.Also i notice,when device in reverse landscape mode , display.getOrientation()
always return 3.
How can i find solution for this problem?