Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically obtain the Android API level of a device?

Tags:

android

How can I find out which API level my device is using?

The firmware version is 1.6. Does that mean it uses API Level 4?

like image 936
user283494 Avatar asked May 04 '10 20:05

user283494


People also ask

How do I know my Android API level?

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.

How can I get Android os programmatically?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken text view to show device version number.

What is API level in Android programming?

API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform. The Android platform provides a framework API that applications can use to interact with the underlying Android system. The framework API consists of: A core set of packages and classes.


Video Answer


1 Answers

You can obtain API level programatically by the system constant (Build.VERSION.SDK_INT). For example you can run some piece of code which requires newer API in the following way (it will execute if the current device's API level is at least 4)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) {  } 

To obtain user visible Android Version use:

Build.VERSION.RELEASE 
like image 117
Arkadiusz Cieśliński Avatar answered Sep 23 '22 21:09

Arkadiusz Cieśliński