1

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 work on a Samsung Galaxy S.

Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192

3 Answers3

3

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;
}
Community
  • 1
  • 1
dev
  • 1,648
  • 16
  • 25
  • that produces 00000000000 which is invalid – zproxy Mar 24 '17 at 20:19
  • Unfortunately there is no surefire method to get the serial as it is vendor specific with variations even between models in the same product line. Please check my other answer linked above for more context on this topic. – dev Mar 24 '17 at 20:39
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:

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

    }
Himanshu Khandelwal
  • 5,341
  • 1
  • 17
  • 7
0

I conclude that it's not possible on Samsung.

Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192