开发者

C2DM with lower API level?

For C2DM to work, a device clearly must be at API level 8. However, does this really require that the application be compiled at that level? None of the code to work with C2DM requires any APIs at level 8. So would it be possible to have an app at a lower level, maybe API level 4 or 6, and have it try to do the C开发者_如何学Go2DM registration? Maybe the registration fails on devices that are at a lower API level, and hopefully this can be detected so that an alternate mechanism could be used. However, shouldn't registration succeed for a device at API level 8 or higher? What I'm trying to do here is take advantage of C2DM while still compiling at level 4, so that my app can reach the most number of users. Ideally this is possible, and I can detect when the device is not capable of C2DM, and react accordingly.


You can use android.os.Build.VERSION.SDK I believe to determine the highest level API the device supports and handle API 8 and <8 separately without requiring the user to be at a certain API level to install the app.


For anyone who comes across this now - android.os.Build.VERSION.SDK is deprecated now, but you can use android.os.Build.VERSION.SDK_INT instead, like so:

    int current_sdk = android.os.Build.VERSION.SDK_INT;

    if (current_sdk >= android.os.Build.VERSION_CODES.FROYO) {
        registerForC2DM(activity);
    }

Here is a reference on all the version codes you can use: http://developer.android.com/reference/android/os/Build.VERSION_CODES.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜