public class AppDisplayManager {
private static AppDisplayManager ourInstance = new AppDisplayManager();
private Display mDisplay;
public static AppDisplayManager getInstance() {
return ourInstance;
}
private AppDisplayManager() {
WindowManager wm =
(WindowManager) CommonUtil.getAppContext().getSystemService(Context.WINDOW_SERVICE);
mDisplay = wm.getDefaultDisplay();
}
public int getDeviceWidth() {
if (null != mDisplay) {
if (android.os.Build.VERSION.SDK_INT >=
android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
Point point = new Point();
mDisplay.getSize(point);
return point.x;
} else {
return mDisplay.getWidth();
}
} else {
return 0;
}
}
public int getDeviceHeight() {
if (null != mDisplay) {
if (android.os.Build.VERSION.SDK_INT >=
android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
Point point = new Point();
mDisplay.getSize(point);
return point.y;
} else {
return mDisplay.getHeight();
}
} else {
return 0;
}
}
}
Comments
Post a Comment