0
我想在android uiautomator測試中添加一項功能,即識別哪個是平板電腦,哪個是手機。如何在uiautomator下獲得android手機屏幕尺寸
你知道,我們用的佈局讓屏幕大小之類的小,中,大,超大,xxlarge
這裏是我的嘗試:
final Configuration config = Resources.getSystem().getConfiguration();
final int screenSizeCode = config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
String screenSize;
switch (screenSizeCode) {
case Configuration.SCREENLAYOUT_SIZE_UNDEFINED:
screenSize = "screen_size_undefined";
break;
case Configuration.SCREENLAYOUT_SIZE_SMALL:
screenSize = "screen_size_small";
break;
case Configuration.SCREENLAYOUT_SIZE_NORMAL:
screenSize = "screen_size_normal";
break;
case Configuration.SCREENLAYOUT_SIZE_LARGE:
screenSize = "screen_size_large";
break;
case Configuration.SCREENLAYOUT_SIZE_XLARGE:
screenSize = "xlarge";
break;
default:
screenSize = "screen_size_unknown";
break;
}
結果是:
screenSize = "screen_size_undefined"
其實我的手機屏幕尺寸是正常。
我想知道如何從uiautomator獲取屏幕大小?
爲什麼device.pressEnter() – 2014-09-09 06:37:07
我想手機輸入像正常,大,xlarge的屏幕尺寸 – 2014-09-09 06:37:59
我的不好..更正了anwser .. – 2014-09-09 09:43:17