我在哪里可以找到代表屏幕方向的整数
问题描述:
我需要将屏幕方向锁定很短的时间,以便用户当前所处的方向。我知道让你做的当前方位:我在哪里可以找到代表屏幕方向的整数
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int orientation = display.getOrientation();
但后来我需要能够比较它代表了不同的方向,像这样的整数:
if (orientation == MysteryAndroidClass.ORIENTATION_PORTRAIT)
{
//lock orientation in portrait
}
else
{
//lock orientation in landscape
}
的问题是,我无法在文档中的任何位置找到这些常量。也许有人知道如何访问它们?
答
你MysteryAndroidClass
是android.content.res.Configuration
int ORIENTATION_LANDSCAPE
int ORIENTATION_PORTRAIT
int ORIENTATION_SQUARE
int ORIENTATION_UNDEFINED
http://developer.android.com/reference/android/content/res/Configuration.html