开发者

How to read serial number on a Samsung device (from within app / on the device)?

How to read the device serial number (not IMEI) of a Samsung Android phone (same value that you get when you call 'adb devices') but from within an app or from the device; not using PC/USB/adb.

I found a solution for HTC and other devices, which is - to call

getprop ro.serialno

in a terminal

as described here,

http://groups.google.com/group/android-developers/browse_thread/thread/3d57b1a214cdf928

but it doesn't开发者_如何学C work on a Samsung Galaxy S.


Edit: You may also want to check my other answer on this topic.

Not sure whether that was possible when the question was first posted. 3 years later however, this is possible:

public static String getManufacturerSerialNumber() {
  String serial = null; 
  try {
      Class<?> c = Class.forName("android.os.SystemProperties");
      Method get = c.getMethod("get", String.class, String.class);
      serial = (String) get.invoke(c, "ril.serialnumber", "unknown");
  } catch (Exception ignored) {}
  return serial;
}


I conclude that it's not possible on Samsung.


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:

try {

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

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

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

    } catch (Exception ignored) {

        serialnum = "unknown";

    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜