I want to set Portrait Orientation
and lock for ldpi and mdpi screens
. and want to set Landscape orientation and lock for hdpi and xhdpi
.
When app opened in 10 inch tablets
it should be landscape
it cant be portrait
. like that when the app opened in android mobile
it should be in portrait
not landscape
.
So please help me to fix this issue.
Please Refer this Question, its works for me :)
How to check an Android device is HDPI screen or MDPI screen?
switch (getResources().getDisplayMetrics().densityDpi) {
case DisplayMetrics.DENSITY_LOW:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case DisplayMetrics.DENSITY_MEDIUM:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case DisplayMetrics.DENSITY_HIGH:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case DisplayMetrics.DENSITY_XHIGH:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
}