How to get the features of Android device

Asked

Viewed 857 times

5

I am beginner in Android development with the SDK platform and would like to know how to get the user device features.

Ex: IMEI, Android version, handset model, etc.

1 answer

2


This information can be obtained by using the Build
It contains several static fields containing information about the device.

Examples:

String produto = Build.PRODUCT;
String modelo = Build.MODEL; 
String fabricante = Build.MANUFACTURER;

In terms of the version of Android use the class Build.VERSION

Examples:

String codeName = Build.VERSION.CODENAME;
String incremental = Build.VERSION.INCREMENTAL; 
String realese = Build.VERSION.RELEASE;

One of the most widely used fields in the class Build.VERSION is Build.VERSION.SDK_INT which, together with the class Build.VERSION_CODES, allows us to easily check the installed version of Android SDK.

Example:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {

     // o código aqui só será executado nas versões 
     // HONEYCOMB ou superior
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.