如何确定哪些安卓设备能运行我的应用程序?

3

在Java中有没有标准的方法来查找我的应用程序可以运行在哪些Android设备上(如平板电脑或手机)?

2个回答

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官方源代码此处
希望这有所帮助!

0

还有android.os.Build类。其中有许多静态常量,包括制造商和型号等。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接