Java中是否有标准方法可以找出我的应用程序将运行哪些Android设备(如平板电脑或手机)?
答案 0 :(得分:3)
这是代码:
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);
}
或者您可以在AndroidManifest.xml中设置补充屏幕:
<manifest ... >
<supports-screens android:xlargeScreens="true" />
...
</manifest>
如果您想了解更多详情,请访问Google IO 2011官方源代码here。
我希望它有所帮助!
答案 1 :(得分:0)
还有android.os.Build类。有许多静态常数,包括制造商和模型等。