How to find serial number of Android device?

后端 未结 17 2178
借酒劲吻你
借酒劲吻你 2020-11-22 14:07

I need to use a unique ID for an Android app and I thought the serial number for the device would be a good candidate. How do I retrieve the serial number of an Android devi

17条回答
  •  佛祖请我去吃肉
    2020-11-22 14:21

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

    This code returns device serial number using a hidden Android API.

提交回复
热议问题