Wednesday, October 6, 2010

How do I – Android: Check current SDK version in application

Its never been easier to check current SDK version your device is running on. Use

Build.VERSION.SDK_INT

it contains value from Build.VERSION_CODES enumeration. For instance, following code determines whether current version is Froyo or higher:

/** 
* Checks if SDK device is running on is Froyo or higher.
 
*
 
*
@return True, if SDK device is running on is Froyo or higher; otherwise false.
 */
public boolean isSdkFroyoOrHigher() {
      return Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO;
}

No comments :

Post a Comment