Search code examples
androidandroid-version

Check api version programatically ICS doesnt work


I want to check if the android version is above ICS:

int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){

I have a code error,

    ICE_CREAM_SANDWICH cannot resolved or it is not a field

But I can read here

http://developer.android.com/reference/android/os/Build.VERSION_CODES.html

this is the correct way, where is the mistake?

Edit after Andy Res answer

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="16" />

But if I check Project->properties->Android, ICS doesn't appear, from Android 3.1 to Android 4.1. I suppose this is the error, how can I solve it?


Solution

  • But if I check Project->properties->Android, ICS doesn't appear, from Android 3.1 to Android 4.1. I suppose this is the error, how can I solve it?

    Use the SDK Manager and download the SDK(s) that you want. They will then appear in the list for you to set your build target.