Reputation: 1889
I need certain activities of mine to only change to landscape if the screen is big enough.
This means tablets and phones with screen size 5.1in+.
Is there anyway to do this through overriding onConfigurationChanged(...) and using the XML statement:
android:configChanges="orientation"
Upvotes: 1
Views: 1607
Reputation: 10641
You certainly can. You can sniff for the screen size and using an if statement if binary or a switch otherwise to set the orientation of the view manually:
Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
screenWidth = (int)(d.getWidth());
screenHeight = (int)(d.getHeight());
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Upvotes: 2