Serial number from Samsung Device running Android
Asked Answered
Q

3

19

I have a Samsung Galaxy Tab 2.0 (7")

On the back of this device is a serial number of the format

RF3C6000MNA

When I go into settings on my device, and choose About Device->Status->Serial Number, this number also appears.

I can't, however, find a way of extracting this number programmatically.

I've seen loads of articles about extracting the serial number, but this returns a completely different number. (using android.os.Build.SERIAL)

I've already extracted the IMEI, and MAC address, so I don't need code for this.

Quiz answered 4/1, 2013 at 16:49 Comment(3)
have you tried how-to-find-serial-number-of-android-device it?Downpipe
Yes, but none of those solutions return the same serial number that's printed on the back of the device, and displayed in the 'Status' screen in settings.Quiz
Possible duplicate of How to read serial number on a Samsung device (from within app / on the device)?Introductory
U
32
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;
}

Edit: it's been a while since this answer, here's a couple of updated points:

  • The OP asked about Galaxy Tab 2 and for that indeed the answer was ril.serialnumber (even for the non-3G model - see this gist). According to Himanshu's answer Galaxy Tab 3 uses sys.serialnumber (also backed by this answer). sys.serialnumber makes better sense for tablets as ril.* stands for Radio Interface Layer, something most tablets are not equipped with (ril.serialnumber, respectively, makes better sense for phones).
  • There is no standard API for getting the device serial number (ie the serial number on the packaging - not to be confused with Settings.Secure.ANDROID_ID or the various other "unique" identifiers scattered throughout the API). This means it is up to the manufacturer to decide where to store the device serial (if at all). On the S3 Mini it's ril.serialnumber, on NexusOne it's ro.serialno (gist), on Galaxy Tab 2 it's ril.serialnumber, on Galaxy Tab 3/4 it's sys.serialnumber, on Lenovo Tab it's none of the above. These settings appear to be the usual suspects, when looking for the device serial, but shouldn't be taken for granted, and as such, shouldn't be relied on for tracking unique app installations.
Urano answered 6/8, 2013 at 4:43 Comment(3)
Fantastic, even Samsung didn't know how to get this. Thank you very much.Quiz
Will this code give the serial number for all manufacturers or only for Samsung galaxy?Embolism
ril.serialnumber works on Galaxy Camera 1 (EK GC100 models), probably Galaxy Camera 2 as well.Trustbuster
C
2

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 in different files and a code has to be device specific.

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

    }
Cutworm answered 6/3, 2014 at 15:4 Comment(0)
R
0

We use the Build class for our product. See if this matches: http://developer.android.com/reference/android/os/Build.html#SERIAL

Radiopaque answered 4/1, 2013 at 19:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.