سؤال

How to get Device Serial Number? I don't want Device ID. I want Serial number (the one which we see in Devices view in Eclipse). If there is no way to get it, can I at least know where is it stored?

هل كانت مفيدة؟

المحلول

As long as you are using API 9

Build.SERIAL

Should return the same value as Eclipse shows.

نصائح أخرى

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:

filename=sys.serial//for samsung tab 3
filename=ro.serial//for samsung t211 tab
filename=ril.serial//for samsung 10inch note
try {

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

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

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

    } catch (Exception ignored) {

        serialnum = "unknown";

    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top