Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何获取设备序列号(非设备ID)_Android_Serial Number - Fatal编程技术网

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

Android 如何获取设备序列号(非设备ID),android,serial-number,Android,Serial Number,如何获取设备序列号?我不想要设备ID,我想要序列号(我们在Eclipse的设备视图中看到的那个)。如果没有办法获取它,我至少可以知道它存储在哪里吗?只要您使用的是API 9 Build.SERIAL 返回的值应与Eclipse显示的值相同。您可以在adb外壳上使用getprop命令,检查哪些文件包含正确的序列号。很多时候序列号位于不同的文件上,并且代码必须是特定于设备的。 You can use the getprop command on the adb shell and check yo

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

只要您使用的是API 9

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

您可以在adb外壳上使用getprop命令,检查哪些文件包含正确的序列号。很多时候序列号位于不同的文件上,并且代码必须是特定于设备的。
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";

    }
对于samung Tab 3,您可以使用以下代码: filename=sys.serial//for samsung tab 3 filename=ro.serial//for samsung t211选项卡 filename=ril.serial//适用于三星10英寸便笺 试一试{ Class c=Class.forName(“android.os.SystemProperties”); 方法get=c.getMethod(“get”,String.class,String.class); serialnum=(字符串)(get.invoke(c,文件名,“未知”); }捕获(忽略异常){ serialnum=“未知”; }
此序列号是否与设备上通常打印的序列号相同?