Checking the Android Version on device at runtime

suggest change

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

To run code only on certain Android versions, check Build.VERSION.SDK_INT before calling APIs that did not exist on older devices. TargetApi tells Lint that the guarded call is intentional.

FingerprintManager and Context.getSystemService(Class) were added in API 23. The check must be >=, so the call does not run on older devices:

@Override
@TargetApi(23)
public void onResume() {
    super.onResume();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        FingerprintManager fingerprintManager = this.getSystemService(FingerprintManager.class);
        //......................
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents