0

I am working on a simple application, it contains two functions. The first function needs some method from 3.0 API (or lower) and the second function needs the 4.4 API.

I would like to one version! If the running environment is a 4.4 Android, the application support the second option. Otherwise the application doesn't give the second function, but the first function is working correctly.

How can I do it?

halfer
  • 19,824
  • 17
  • 99
  • 186
Gregory01
  • 97
  • 10
  • sounds to me like you'd like to check if a certain method exists. If it does do functionA else do functionB. Use [reflection](http://stackoverflow.com/a/10876603/736967) – Ronnie Feb 23 '15 at 18:28

2 Answers2

1

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 minSdkVersion is set to anything less than 4, then you will have to use android.os.Build.VERSION.SDK, which is a String that 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.

See this answer: Get Android API level of phone currently running my application

Community
  • 1
  • 1
Erdinc Ay
  • 3,224
  • 4
  • 27
  • 42
0

I found it, unfortunatelly I must maintain two source: http://developer.android.com/training/multiple-apks/api.html

Gregory01
  • 97
  • 10