Android: Get Hardware Information Programmatically

折月煮酒 提交于 2019-11-27 00:50:35
Richa
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

    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);
cadavre

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.

**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;
    

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!