If you're just trying to determine the heights and widths for portrait and landscape, you could just quickly force the orientation both ways and get the metrics each way. The following snippet does that. The code is guarded by a simple preference check since I tested this in onCreate()
and the orientation changes will cause an activity restart (and go into a loop). In your app, you'll probably want to do something more specific. Also, all of the methods used are valid down to API 1, but may have been replaced or renamed in higher versions.
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getBoolean("firstTime", true)) {
prefs.edit().putBoolean("firstTime", false).commit();
DisplayMetrics dm = new DisplayMetrics();
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
getWindowManager().getDefaultDisplay().getMetrics(dm);
Log.e(TAG, String.format("landscape is %d x %d", dm.widthPixels, dm.heightPixels));
// Do something with the values, perhaps saving them in prefs
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getWindowManager().getDefaultDisplay().getMetrics(dm);
Log.e(TAG, String.format("portrait is %d x %d", dm.widthPixels, dm.heightPixels));
// Do something with the values, perhaps saving them in prefs
}