gpt4 book ai didi

java - 如何实现 isMyDeviceATablet() 方法?

转载 作者:行者123 更新时间:2023-12-02 07:46:26 26 4
gpt4 key购买 nike

我想检查我的设备是否是平板电脑。

方法 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com