57

我需要在运行我的应用程序的 Android 设备上获取硬件相关信息。我需要以下类型的信息。

  • CPU 制造商、型号和序列号
  • SD 卡制造商和序列号
  • 相机制造商和其他相关规格
  • 蓝牙相关硬件信息
  • WiFi相关硬件信息
  • RAM 供应商/型号
  • 显示供应商和型号

对此主题的任何帮助将不胜感激。

4

6 回答 6

41
    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);
于 2016-05-18T11:23:43.523 回答
38
Log.i("ManuFacturer :", Build.MANUFACTURER);
Log.i("Board : ", Build.BOARD);
Log.i("Display : ", Build.DISPLAY);

更多信息可以在http://developer.android.com/reference/android/os/Build.html找到

于 2012-05-08T10:35:18.963 回答
11

**此代码为您提供以下信息**

  1. 设备制造商
  2. 模型
  3. 木板
  4. 硬件
  5. 序列号。
  6. Android_ID
  7. 屏幕分辨率
  8. 屏幕密度
  9. 引导加载程序
  10. 用户
  11. 主持人
  12. API 级别
  13. 构建 ID
  14. 构建时间
  15. 指纹

        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;
    
于 2018-05-17T09:52:42.967 回答
6

您还可以获得实时硬件信息。Build.* 参数在 Android 编译期间设置,甚至在将其部署到硬件本身之前。

您可以通过读取 /proc/* "files" 访问 Linux 实时硬件信息。

您可以使用 https://stackoverflow.com/a/3528239/997381做到这一点

就像命令一样cat /proc/cpuinfo

您可以使用 进行测试adb shell,并且不需要 root 权限。

于 2014-04-15T08:34:59.500 回答
4

也许有人需要 kotlin 解决方案

例子

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?
}
于 2019-11-07T12:02:44.293 回答
1

android.os 中的“Build”类看起来会包含一些您需要的信息

用它作为

string build = Build.VERSION.DEVICE;

安卓硬件信息

于 2012-05-08T10:36:15.290 回答