获取Android设备硬件序列号 [英] Get hardware serial number of Android device

查看:2519
本文介绍了获取Android设备硬件序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的是安装我的应用程序的Andr​​oid设备的硬件序列code。这种硬件序列号是一个你可以在设置&gt看;关于装置>状态>序列号

I need to get the hardware serial code of Android device where my app is installed. This hardware serial number is the one that you can see on Settings > About Device > Status > Serial number.

不过,我觉得我会用它获得 Settings.Secure.ANDROID_ID或android.os.Build.SERIAL ,但都没有工作,这意味着他们没有给我唯一​​标识符我在寻找。例如 android.os.Build.SERIAL 让我当你运行该命令对亚行显示的唯一ID的 ADB设备

I though I would get it using Settings.Secure.ANDROID_ID or android.os.Build.SERIAL, but neither of them worked, meaning that they didn't give me unique identifier I'm looking for. For instance android.os.Build.SERIAL got me the unique ID shown on ADB when you run the command adb devices.

请注意,这个问题的目标不是找到另外一个唯一的标识符,可以帮助我,这只是有关获取设备硬件序列号。

Notice that the goal of this question is not to find another unique identifier that could help me, it's only about getting the device hardware serial number.

感谢您的帮助。

编辑:

请清楚,我不是在寻找的字符串android.os.BUILD.SERIAL提供的值。我知道如何获得该值,但我不感兴趣。

Please be clear that I'm not looking for the value provided by the String android.os.BUILD.SERIAL. I know how to get that value but I'm not interested in it.

我有一个三星的设备,因此,他们所使用的序列号是比android.os.BUILD.SERIAL提供的不同。

I have a Samsung device, therefore, the serial number they used is different than the one provided by android.os.BUILD.SERIAL.

推荐答案

解决的办法很简单:

Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class, String.class);
serialNumber = (String) get.invoke(c, "sys.serialnumber", "Error");
if(serialNumber.equals("Error")) {
    serialNumber = (String) get.invoke(c, "ril.serialnumber", "Error");
}

这将让你最三星设备的序列号。我用的是sys.serialnumber值来得到我的SM-T210(Galaxy Tab的3)和SM-T230(Galaxy Tab的4)平板电脑的序列号,但可能有更多的三星平板电脑的工作原理。而ril.serialnumber是为了让我的三星GT-I8550L(银河赢)的值。

This will get you the serial number of most samsung devices. I use the "sys.serialnumber" value to get the serial number of my SM-T210 (Galaxy Tab 3) and SM-T230 (Galaxy Tab 4) tablets, but probably works with a lot more Samsung tablets. The "ril.serialnumber" is to get the value on my Samsung GT-I8550L (Galaxy Win).

我希望这有助于。

这篇关于获取Android设备硬件序列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆