Is there any API in the Android SDK that allows me to get the API version that the phone is currently running?
+3
A:
Got it. Its using the getApplicationInfo() method of the Context class. :)
Parth Mehta
2010-08-06 12:41:19
A:
android.os.Build.VERSION.SDK should give you the value of the API Level. You can easily find the mapping from api level to android version in the android documentation. I believe, 8 is for 2.2, 7 for 2.1, and so on.
jvdneste
2010-08-06 12:44:28
A:
As described in the android documentation, the SDK level (integer) the phone is running is available in:
android.os.Build.VERSION.SDK_INT;
The enum corresponding to this int is in the android.os.Build.VERSION_CODES class.
Code example:
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.FROYO){
// Do something for froyo and above versions
} else{
// do something for phones running an SDK before froyo
}
Corresponding android documentation:
http://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT
http://developer.android.com/reference/android/os/Build.VERSION_CODES.html
ol_v_er
2010-10-15 09:01:31