1

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?

3 Answers3

2

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
2

Simply use this

int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= 14){
vaibhav kumar
  • 414
  • 2
  • 11
1

Make sure the project build target is Android 4.0 or higher.

(Assuming you use Eclipse, you would do this by: Right clicking on the project -> Properties -> From the left menu click on Android -> then choose the target)

Andy Res
  • 15,963
  • 5
  • 60
  • 96