Getting the features of your Android device

5

I'm a beginner in Android development with the SDK platform and would like to know how to get the features of the user's device.

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

    
asked by anonymous 03.10.2015 / 07:27

1 answer

2

This information can be obtained by using the class 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 Android version, refer to the class Build.VERSION

Examples:

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

One of the most used fields in the Build.VERSION class is Build.VERSION.SDK_INT , together with the class Build.VERSION_CODES , allows us to easily check the version installed from the 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
}
    
03.10.2015 / 12:39