4

I'm working on the recurring serial number topic to provide a unique id.

I try this :

       String serial = null; 

        try {
            Class<?> c = Class.forName("android.os.SystemProperties");
            Method get = c.getMethod("get", String.class);
            serial = (String) get.invoke(c, "ro.serialno");
        } catch (Exception ignored) {
        }

and

        StringBuilder sb = new StringBuilder();
        sb.append("SERIAL ").append(android.os.Build.SERIAL).append("\n");


        textReportAdmin.setText(
                sb.toString());

Both gives the same value : C4F12FDD949F22F

On the box and on the sticker of my tab, the serial number is : RF2C202WYME

I work on a tab, no way to use

    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    String imei = telephonyManager.getDeviceId();

IMEI is empty in my case.

SERIAL is what I need, but I need it in clear version as displayed on the sticker upon the barcode behind the tab.

I guess it is possible as, When going in the system app, and looking at the state of the device, it is displayed in clear...

How to convert the value returned by android.os.Build.SERIAL to the human visible one ?

EDITION : I also looked in :

        sb.append("PRODUCT ").append(android.os.Build.PRODUCT).append("\n");
        sb.append("BOARD ").append(android.os.Build.BOARD).append("\n");
        sb.append("BOOTLOADER ").append(android.os.Build.BOOTLOADER).append("\n");
        sb.append("BRAND ").append(android.os.Build.BRAND).append("\n");
        sb.append("CPU_ABI ").append(android.os.Build.CPU_ABI).append("\n");
        sb.append("CPU_ABI2 ").append(android.os.Build.CPU_ABI2).append("\n");
        sb.append("DEVICE ").append(android.os.Build.DEVICE).append("\n");
        sb.append("DISPLAY ").append(android.os.Build.DISPLAY).append("\n");
        sb.append("FINGERPRINT ").append(android.os.Build.FINGERPRINT).append("\n");
        sb.append("HARDWARE ").append(android.os.Build.HARDWARE).append("\n");
        sb.append("HOST ").append(android.os.Build.HOST).append("\n");
        sb.append("ID ").append(android.os.Build.ID).append("\n");
        sb.append("MANUFACTURER ").append(android.os.Build.MANUFACTURER).append("\n");
        sb.append("MODEL ").append(android.os.Build.MODEL).append("\n");
        sb.append("PRODUCT ").append(android.os.Build.PRODUCT).append("\n");
        sb.append("RADIO ").append(android.os.Build.RADIO).append("\n");
        sb.append("SERIAL ").append(android.os.Build.SERIAL).append("\n");
        sb.append("TAGS ").append(android.os.Build.TAGS).append("\n");
        sb.append("TIME ").append(android.os.Build.TIME).append("\n");
        sb.append("TYPE ").append(android.os.Build.TYPE).append("\n");
        sb.append("USER ").append(android.os.Build.USER).append("\n");

nowhere, I get the serialnumber as on the sticker, while it can be possible to be found as ,the system itself is able to display it in "Parameters", "About", "State" (I don't know the words in english, I have a french tab, and it is "Paramètres", "A propos de", "Etat" and then "Serial Number", the clear version, as on the sticker.

christophe46
  • 41
  • 1
  • 1
  • 5
  • Is using Serial really good as identifier? `A hardware serial number, if available` – keiki Aug 03 '12 at 11:26
  • http://stackoverflow.com/questions/2322234/how-to-find-serial-number-of-android-device is a better advice. – keiki Aug 03 '12 at 11:31
  • 1
    What is your proof that your "recurring serial number" that you are getting by unsupported means will be a reliable "unique id"? How are you going to force all device manufacturers to ensure that this value exists and is unique across manufacturers? How will you address the hundreds of millions of devices that already exist? How will you address the ROM mods that can change these values at will? How will you force Google to not get rid of your ability to read this value via reflection? – CommonsWare Aug 03 '12 at 11:52
  • I need to get the serial number as displayed on the sticker on the box and behind the tab. It is possible, as in "Parametres", "A propos de", "Etat", the serial number is clearly displayed as on the box and on the sticker. It's for maintenance purpose, not for fraud hunting. I need something that any human without a high degree is able to see "please turn your tab and read me the number on the sticker please". – christophe46 Aug 03 '12 at 12:04
  • i have well read all the links you gave me (my test code comes from them...). NO where I read info about how to format correctly android.os.SERIAL to get the "human readable" serial number as on the barcode neither it is the right value ! – christophe46 Aug 03 '12 at 12:10
  • So my right question should be : how to get the serial number on android tabs in order to get the same value than on the sticker and as displayed in the "a propos" box of the system parameters. – christophe46 Aug 03 '12 at 12:17
  • From the Home screen, press Menu. 2. Select Settings 3. Choose About device. 4. Select Status. 5. The MEID or ESN will be located on this screen. – christophe46 Aug 03 '12 at 12:20
  • It is the ESN as displayed there I need to get for my purpose. – christophe46 Aug 03 '12 at 12:21
  • What makes you think that the value on some sticker is necessarily going to be reflected in the device anywhere? For example, on both my Galaxy Nexus and my Nexus S, the value reported in "Status" is not the same as the value on the sticker beneath the battery. The value that will be printed on some sticker, or even if there is such a sticker, is going to be up to the device manufacturer and may not be related to anything from the Settings app. – CommonsWare Aug 03 '12 at 12:40
  • on my fresh new galaxy tab out of the box, the sticker on the box, on the back of the tab and on the info screen on the system are the same and my question is : how to get THIS information ? – christophe46 Aug 03 '12 at 13:31
  • google/android itself find it safe to display it as it is the serial number info in the status box.... – christophe46 Aug 03 '12 at 13:33
  • i need to use THIS information. it's not for security purpose, it is just for maintenance purpose and need to be easy to be found by the user itself to give it to a hotline. on top of this, there is a login, a password, a rest service with authentification, many other things, but in our process we want to get this serial number – christophe46 Aug 03 '12 at 13:35

4 Answers4

7

Have you tried this?

String serial = null; 

try {
     Class<?> c = Class.forName("android.os.SystemProperties");
     Method get = c.getMethod("get", String.class);
     serial = (String) get.invoke(c, "ril.serialnumber");
 } catch (Exception ignored) {
 }
Jonathan Liono
  • 556
  • 4
  • 13
6

If you want to get the serial number as shown on the back of the device and if you are using the Samsung Galaxy Tab then why not use the 'ril.serialnumber' property

Items changed to what your device should show:

$ adb shell getprop | grep serial
[ril.serialnumber]: [RF2C202WYME]
[ro.boot.serialno]: [c4f12fdd949f22f]
[ro.serialno]: [c4f12fdd949f22f]

Pre-jellybean 'ro.boot.serialno' didn't exist

James
  • 61
  • 1
  • 2
1

On many devices there is information displayed in the Settings --> About activity that is non-standard and is not available from any standard Android API. For example, the FCC ID is sometimes displayed there but is not available to apps.

Also, there is no requirement that the serial number available through the API's be the product's 'real' serial number (i.e. the one on the package). Just that it be unique.

So, I think there is no way to do what you want (read the serial number that is on the box and in the about activity) other then look through that product's source code (if available) and see if there is a way to get that info for that particular product or manufacturer.

Tom
  • 17,103
  • 8
  • 67
  • 75
1

you should use sys.serialnumber ,some devices have ril.serialnumber and some have sys.serialnumber ,so you should try sys one

android_guy
  • 152
  • 1
  • 2
  • 14