【问题标题】:Using ICS functions in an application targeted for Gingerbread在针对 Gingerbread 的应用程序中使用 ICS 函数
【发布时间】:2013-01-18 07:41:42
【问题描述】:

当我们的应用程序以 Gingerbread 为目标时,如何合并来自 ICS 或 Jelly Bean 的功能?如何防止我收到编译错误?

比如说我希望我的应用程序使用类似 android.renderscript.ScriptIntrinsicBlend 的东西。当用户使用 Gingerbread 时,我无法使用它,但如何启用 ICS 用户使用它的选项?当我为 Gingerbread 目标应用程序编写代码时,出现错误。

如何防止这些错误?

【问题讨论】:

    标签: java android


    【解决方案1】:

    你可以这样做:

    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
        // code for ICS and above versions
    } else{
        // code for phones running an SDK before ICS
    }
    

    http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

    【讨论】:

    • 非常感谢米哈尔!非常感谢!
    猜你喜欢
    • 2012-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多