我想检查我的设备是否是平板电脑。
方法 isMyDeviceATablet() 或 isMyDeviceATablet(Context context) 的最佳实现是什么?
最佳答案
来自 Google I/O 2011 应用:
public static boolean isHoneycomb() {
// Can use static final constants like HONEYCOMB, declared in
// later versions of the OS since they are inlined at compile
// time. This is guaranteed behavior.
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
}
public static boolean isTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK)
>= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
public static boolean isHoneycombTablet(Context context) {
return isHoneycomb() && isTablet(context);
}
关于java - 如何实现 isMyDeviceATablet() 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10779404/