Can I get the Android API version with the code?

Asked 2 years ago, Updated 2 years ago, 34 views

Is there an API in the Android SDK that allows you to know the API version from the currently running program?

api android android-api-levels

2022-09-22 15:14

1 Answers

If you look at the Android document, android.os.Build.VERSION.SDK_INT There's something like this.

int currentapiVersion = android.os.Build.VERSION.Gets the level of SDK_INT; //SDK. 
if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP){
    // The current device version is Lollipop or higher.
} } else{
    // The current device version is less than Lollipop. 
}


2022-09-22 15:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.