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

时间:2012-10-08 14:26:42

标签: android serial-number

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

2 个答案:

答案 0 :(得分:1)

只要您使用API​​ 9

Build.SERIAL

应返回与Eclipse显示的值相同的值。

答案 1 :(得分:0)

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

    }