Essential Android Android Versions edit forum

Checking the Android Version on device at runtime

Build.VERSION_CODES is an enumeration of the currently known SDK version codes.

In order to conditionally run code based on the device’s Android version, use the TargetApi annotation to avoid Lint errors, and check the build version before running the code specific to the API level.

Here is an example of how to use a class that was introduced in API-23, in a project that supports API levels lower than 23:

@Override
@TargetApi(23)
public void onResume() {
    super.onResume();
    if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
        //run Marshmallow code
        FingerprintManager fingerprintManager = this.getSystemService(FingerprintManager.class);
        //......................
    }
}
Android Versions/
Android Versions
Checking the Android Version on device at runtime

Table Of Contents
39 ACRA
64 Menu
81 Android Versions
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close