Possible Duplicate:
Programmatically obtain the Android API level of a device?
How do I get the Api level of the phone curently running my application? I am sure its simple but I can not find it as all my searches bring up tons of junk.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Check
android.os.Build.VERSION, which is a static class that holds various pieces of information about the Android OS a system is running.If you care about all versions possible (back to original Android version), as in
minSdkVersionis set to anything less than 4, then you will have to useandroid.os.Build.VERSION.SDK, which is aStringthat can be converted to the integer of the release.If you are on at least API version 4 (Android 1.6 Donut), the current suggested way of getting the API level would be to check the value of
android.os.Build.VERSION.SDK_INT, which is an integer.In either case, the integer you get maps to an enum value from all those defined in
android.os.Build.VERSION_CODES:Note that some time between Android N and O, the Android SDK began aliasing
CUR_DEVELOPMENTand the developer preview of the next major Android version to be the sameSDK_INTvalue (10000).