繁体   English   中英

如何获取设备序列号(不是设备ID)

[英]How to get Device Serial Number (Not Device ID)

如何获得设备序列号? 我不需要设备ID。 我想要序列号(我们在Eclipse的“设备”视图中看到的序列号)。 如果没有办法,至少可以知道它存储在哪里吗?

只要您使用的是API 9

Build.SERIAL

应该返回与Eclipse所示相同的值。

You can use the getprop command on the adb shell and check yourself that which of the files contains the correct Serial number.Many times the serial number is located on different files and code has to be device specific.

Foe samung Tab 3 you can use the following code:

filename=sys.serial//for samsung tab 3
filename=ro.serial//for samsung t211 tab
filename=ril.serial//for samsung 10inch note
try {

        Class<?> c = Class.forName("android.os.SystemProperties");

        Method get = c.getMethod("get", String.class, String.class);

        serialnum = (String) (get.invoke(c, filename, "unknown"));

    } catch (Exception ignored) {

        serialnum = "unknown";

    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM