int currentOrientation = getResources().getConfiguration().orientation;
if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if(currentOrientation == Configuration.ORIENTATION_LANDSCAPE){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
This is the code is used for locking screen orientation programatically. But it is not working for reverse portrait and reverse landscape. What could be the solution.
Here is the code to get current orientation in constants of
ActivityInfo
classHow to use in your case:
If it was usefull, please refer to this answer