C2DM with a lower API level?

For C2DM to work, the device must explicitly be at API level 8. However, is it really necessary that the application be compiled at this level? None of the code for working with C2DM requires any APIs at level 8. Thus, is it possible to have the application at a lower level, perhaps at the level of API 4 or 6, and try to register C2DM? Perhaps registration does not work on devices with a lower API level, and I hope this can be detected so that an alternative mechanism can be used. However, to prevent registration for a device at API level 8 or higher? What I'm trying to do here is to use C2DM while still compiling at level 4 so that my application can reach the largest number of users. Ideally, this is possible, and I can detect when a device is not capable of C2DM,and respond accordingly.

+3
source share
2 answers

You can use android.os.Build.VERSION.SDK, I believe, to determine the highest level API supported by the device and process the API 8 and <8 separately, without requiring the user to be at a certain API level to install the application.

+2
source

For those who are facing this now - android.os.Build.VERSION.SDK is deprecated now, but instead you can use android.os.Build.VERSION.SDK_INT, for example:

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

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

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

0
source

Source: https://habr.com/ru/post/1772268/


All Articles