Rahul Nagane
Rahul Nagane

Reputation: 131

how to identify that which android os user device is using?

i want to check the version of android operating system installed on user device. can i find it using android.os.Build.VERSION_CODES or something else. please provide code.

Upvotes: 1

Views: 66

Answers (3)

Emdad Hossain
Emdad Hossain

Reputation: 387

As described on Android Documentation API level can be retrieved using

android.os.Build.VERSION.SDK_INT

The class corresponding to this int is in the android.os.Build.VERSION_CODES class.

Code example:

int currentapiVersion = android.os.Build.VERSION.SDK_INT;

Log.d("sdk version",""+currentapiVersion );


if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP){
    // Do something for lollipop and above versions
} else{
    // do something for phones running an SDK before lollipop
}

Upvotes: 1

CommonsWare
CommonsWare

Reputation: 1006724

Build.VERSION.SDK_INT tells you the API level that the device runs, which is usually all that a developer will need.

There are other fields on Build.VERSION that may be of interest to you, if your goal is to display that information to users.

Upvotes: 0

Rex Lam
Rex Lam

Reputation: 1405

You can check with android.os.Build.VERSION.SDK_INT To check if device is running Android lollipop or above :

if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
  // do something
}

Details: https://developer.android.com/reference/android/os/Build.VERSION.html

Upvotes: 0

Related Questions