在ICE(冰淇淋三明治)上运行的Android Honeycomb应用程序

时间:2012-01-16 06:05:15

标签: android screen android-3.0-honeycomb android-4.0-ice-cream-sandwich

我有一个为Honeycomb开发的应用程序(最初是3.0),在ICS发布后,用户可以将它安装到带有ICS的手机上,而不仅仅是平板电脑。我该如何过滤这些手机?我试过了<support-screens>,但是没有用。另外一个有趣的(至少对我而言)我的应用程序不会缩小到较小的屏幕。我使用固定大小的控件,但大小是dp。

简而言之:

  1. 有人知道如何过滤ICS手机? (最好来自代码)
  2. 我该怎么做才能支持ICS手机? (我想我需要为ICS手机实现一个全新的布局,但我仍然有一个问题,我如何确定它是什么类型的设备,手机或平板电脑?

3 个答案:

答案 0 :(得分:1)

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);
}

从这里回答:https://stackoverflow.com/a/8427523/253583

您可能还希望限制Android电子市场,使其能够在您的清单中http://developer.android.com/guide/topics/manifest/supports-screens-element.html的手机上安装此功能。

答案 1 :(得分:0)

您可以使用

进行检查
if(Build.VERSION.SDK_INT >= 14) {
    //ics
}

其中Build是android.os.Build类

答案 2 :(得分:0)

如果您只希望自己的应用在平板电脑市场中展示,请在AndroidManifest.xml中使用<support-screens>属性(更多信息here)。确保在Honeycomb 3.2(x-large,large)和3.2+(600dp等)之前使用两个标识符。

你的意思是“我的应用程序不缩小”到底是什么意思?你能在这里提供更多信息吗?