how to decode android.os.Build.SERIAL?

christophe46 picture christophe46 · Aug 3, 2012 · Viewed 9.6k times · Source

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.

Answer

Jonathan Liono picture Jonathan Liono · Mar 6, 2013

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) {
 }