How can i get the current android deveice version (1.5, 1.6, 2.0, etc.) programmatically. i.e I have installed my apk in ANdroid 2.2 device.. I need to get the device version (android emulator version in which my application is currently running )
Asked
Active
Viewed 8,049 times
2
-
2Already answered in http://stackoverflow.com/questions/3423754/retrieving-android-api-version-programmatically – kgiannakakis Feb 24 '11 at 12:23
2 Answers
10
The integer representing the API level can be found at android.os.Build.VERSION.SDK_INT
So you could do:
int apiLevel = android.os.Build.VERSION.SDK_INT;
The possible values of that integer across all devices can be found in here. If you want to compare versions against a named release of android, use the name of each constant here. You cannot compare the device version against the release numbers like 2.1 , 2.2 etc. so if you want to do that you must use the release name or API level, and then convert manually.

Jems
- 11,560
- 1
- 29
- 35
-
2Keep in mind that android.os.Build.VERSION.SDK_INT is supported since API level 4 (1.6) – Maaalte Feb 24 '11 at 12:40
6
Look at following post might help How can I check in code the Android version like 1.5 or 1.6

Community
- 1
- 1

ingsaurabh
- 15,249
- 7
- 52
- 81
-
but my need is to get my target device 's OS version (15,2.1,2.2) in which my application is installed – jennifer Feb 24 '11 at 12:22
-
1the use following int currentapiVersion = android.os.Build.VERSION.SDK_INT; – ingsaurabh Feb 24 '11 at 12:35