我有下面的代碼來發現屏幕尺寸:的NoSuchMethodError:的getSize
WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
Point size = new Point();
int measuredWidth = 0;
int measuredHeight = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
wm.getDefaultDisplay().getSize(size);
measuredWidth = size.x;
measuredHeight = size.y;
} else {
Display display = wm.getDefaultDisplay();
measuredWidth = display.getWidth();
measuredHeight = display.getHeight();
}
在一個星系GIO(2.3.6)這工作,但Galaxy Tab的10.1(3.0)在此崩潰。
wm.getDefaultDisplay().getSize(size);
在此行中我得到
NoSuchMethodError: android.view.Display.getSize.
我該如何解決這個問題?