0

I would like to check in which platform my app is running.

To be more accurate, I would like to check if my app is running on Android v3.2 and greater or running on a platform older than Android v3.2 .

But I have no idea how to make this kind of checking in Java code ? Any one can help me?

Leem.fin
  • 35,699
  • 70
  • 166
  • 297

2 Answers2

2

Use this: android.os.Build.VERSION.SDK_INT; It returns the API level.

Thommy
  • 4,644
  • 2
  • 23
  • 43
  • Note that Build.VERSION.SDK_INT is only available on Android 1.6 and newer. Build.VERSION.SDK will work on all Android releases, including 1.5. However, once you elect to drop 1.5 support, switching to SDK_INT is a good idea. **Read this comment at http://stackoverflow.com/a/1883201/379693** – Paresh Mayani Feb 23 '12 at 10:49
  • you should comare it to fx.: Build.VERSION_CODES.HONEYCOMB_MR2 ... more info about Build.VERSION_CODES take from sankar answer – Selvin Feb 23 '12 at 10:51
  • @PareshMayani API 1.5 ... well there were only one or two phones with this API and we should not bother about this version – Selvin Feb 23 '12 at 10:54
0

you can check by using android.os.Build.VERSION_CODES it will return current android version code

Refer this link

http://developer.android.com/reference/android/os/Build.VERSION_CODES.html

Sankar
  • 1,595
  • 2
  • 15
  • 25