57

I have a requirement for obtaining the hardware related information on an Android device that runs my application. I need information of the following sort.

  • CPU Manufacturer, model and serial number
  • SD Card Manufacturer and serial number
  • Camera Manufacturer and other related specs
  • Bluetooth related hardware information
  • WiFi related hardware information
  • RAM Vendor / model
  • Display vendor and model

Any help on this topic would be highly appreciated.

Heshan Perera
  • 4,392
  • 8
  • 41
  • 57

6 Answers6

42
    Log.i("TAG", "SERIAL: " + Build.SERIAL);
    Log.i("TAG","MODEL: " + Build.MODEL);
    Log.i("TAG","ID: " + Build.ID);
    Log.i("TAG","Manufacture: " + Build.MANUFACTURER);
    Log.i("TAG","brand: " + Build.BRAND);
    Log.i("TAG","type: " + Build.TYPE);
    Log.i("TAG","user: " + Build.USER);
    Log.i("TAG","BASE: " + Build.VERSION_CODES.BASE);
    Log.i("TAG","INCREMENTAL " + Build.VERSION.INCREMENTAL);
    Log.i("TAG","SDK  " + Build.VERSION.SDK);
    Log.i("TAG","BOARD: " + Build.BOARD);
    Log.i("TAG","BRAND " + Build.BRAND);
    Log.i("TAG","HOST " + Build.HOST);
    Log.i("TAG","FINGERPRINT: "+Build.FINGERPRINT);
    Log.i("TAG","Version Code: " + Build.VERSION.RELEASE);
Yamini
  • 623
  • 7
  • 10
38
Log.i("ManuFacturer :", Build.MANUFACTURER);
Log.i("Board : ", Build.BOARD);
Log.i("Display : ", Build.DISPLAY);

More info can be found at from http://developer.android.com/reference/android/os/Build.html

Chirag Ravindra
  • 4,485
  • 1
  • 20
  • 34
Richa
  • 3,157
  • 1
  • 20
  • 25
  • 2
    Yes I saw this, but it does not meet my requirement. It does not provide me with any information such as the CPU vendor, clock speed etc. Is there a way to access that info through this class ? – Heshan Perera May 08 '12 at 10:38
  • I would also like to know the device camera specs – Lou Morda Jun 03 '15 at 03:24
11

**This Code give you information about following **

  1. Manufacturer of device
  2. Brand
  3. Model
  4. Board
  5. Hardware
  6. Serial No.
  7. Android_ID
  8. Screen Resolution
  9. Screen Density
  10. Boot Loader
  11. User
  12. Host
  13. API Level
  14. Build ID
  15. Build Time
  16. Fingerprint

        DisplayMetrics dm = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
        double x = Math.pow(mWidthPixels / dm.xdpi, 2);
        double y = Math.pow(mHeightPixels / dm.ydpi, 2);
        screenInches = Math.sqrt(x + y);
        rounded = df2.format(screenInches);
        densityDpi = (int) (dm.density * 160f);
    
    
    
    
    Manufacturer_value = Build.MANUFACTURER;
    Brand_value = Build.BRAND;
    Model_value = Build.MODEL;
    Board_value = Build.BOARD;
    Hardware_value = Build.HARDWARE;
    Serial_nO_value = Build.SERIAL;
    UID_value = tManager.getDeviceId();
    android_id = 
    Settings.Secure.getString(getContext().getContentResolver(), 
    Settings.Secure.ANDROID_ID);
    ScreenResolution_value = mHeightPixels + " * " + mWidthPixels + " Pixels";
    screen_size = rounded + " Inches";
    screen_density = String.valueOf(densityDpi) + " dpi";
    BootLoader_value = Build.BOOTLOADER;
    User_value = Build.USER;
    Host_value = Build.HOST;
    Version = Build.VERSION.RELEASE;
    API_level = Build.VERSION.SDK_INT + "";
    Build_ID = Build.ID;
    Build_Time = Build.TIME + "";
    Fingerprint = Build.FINGERPRINT;
    
M Talha
  • 161
  • 1
  • 8
6

You can also get real-time hardware info. Build.* parameters are set during compilation of Android before even deploying it on hardware itself.

You can access Linux real-time hardware info by reading /proc/* "files".

You can do that with https://stackoverflow.com/a/3528239/997381

Simply as command put cat /proc/cpuinfo.

You can test this with adb shell, and you don't need root permissions.

Community
  • 1
  • 1
cadavre
  • 1,214
  • 1
  • 16
  • 33
4

maybe someone needs kotlin solution

example

class DeviceInfoHelper constructor(val context: Context) {

    val model = deviceModel

    val imei = context.imei

    val hardware: String? = HARDWARE

    val board: String? = BOARD

    val bootloader: String? = BOOTLOADER

    val user: String? = USER

    val host: String? = HOST

    val version: String? = RELEASE

    val apiLevel = SDK_INT

    val id: String? = ID

    val time = TIME

    val fingerPrint: String? = FINGERPRINT

    val display: String? = DISPLAY

    private val deviceModel
        @SuppressLint("DefaultLocale")
        get() = capitalize(
                if (MODEL.toLowerCase().startsWith(MANUFACTURER.toLowerCase())) {
                    MODEL
                } else {
                    "$MANUFACTURER $MODEL"
                })


    private fun capitalize(str: String) = str.apply {
        if (isNotEmpty()) {
            first().run { if (isLowerCase()) toUpperCase() }
        }
    }

    private val Context.imei
        @SuppressLint("HardwareIds", "MissingPermission")
        get() = telephonyManager?.run {
            if (isReadPhoneStatePermissionGranted()) {
                if (SDK_INT >= VERSION_CODES.O) {
                    imei
                } else {
                    deviceId
                }
            } else DEFAULT_DEVICE_ID
        } ?: DEFAULT_DEVICE_ID

    private fun Context.isReadPhoneStatePermissionGranted() =
            ContextCompat.checkSelfPermission(
                    this,
                    Manifest.permission.READ_PHONE_STATE
            ) == PackageManager.PERMISSION_GRANTED

    private val Context.telephonyManager
        get() = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager?
}
Mahmudul Hasan Shohag
  • 1,334
  • 15
  • 23
Cube
  • 304
  • 3
  • 8
1

The "Build" class in android.os looks like it will contain some of the information you require

use it as

string build = Build.VERSION.DEVICE;

android Hardware Info

ry8806
  • 2,121
  • 1
  • 21
  • 27
  • you cannot assign `Build.VERSION` to a String. It gives compilation error. Instead you can have `Build.VERSION.`_SOMETHING_ (As example **RELEASE** ) and assign it to String. Else you can assign `Build.`_SOMETHING_ (As example **DISPLAY** ) to a String variable. [Android Build](http://developer.android.com/reference/android/os/Build.html) and [Android Build.VERSION](http://developer.android.com/reference/android/os/Build.VERSION.html)Isn't it? – AnujAroshA Jun 11 '12 at 11:44
  • [`Build.VERSION`](https://developer.android.com/reference/android/os/Build.VERSION.html) does not have a `DEVICE` field, [`Build`](https://developer.android.com/reference/android/os/Build.html) itself does. Though, the `String` provided by `Build.DEVICE` only contains the name of the device itself, not any of the information the question asks about. – Bryan Aug 31 '16 at 12:42