Pages Navigation Menu

Coding is much easier than you think

How to get android api version programmatically

 
There is different ways to get that programmatically .

First method .

The SDK level (integer) the phone is running is available in:
 

android.os.Build.VERSION.SDK_INT;

 
** UPDATE: Android Complete tutorial now available here.
 
The enum corresponding to this int is in the android.os.Build.VERSION_CODES class.
 

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
}