获取Android设备唯一号

来源:互联网 发布:淘宝拍拍网 编辑:程序博客网 时间:2024/06/06 06:52

public class PropertyUtils {

private static volatile Method set = null;private static volatile Method get = null;public static void set(String prop, String value) {    try {        if (null == set) {            synchronized (PropertyUtils.class) {                if (null == set) {                    Class<?> cls = Class.forName("android.os.SystemProperties");                    set = cls.getDeclaredMethod("set", new Class<?>[]{String.class, String.class});                }            }        }        set.invoke(null, new Object[]{prop, value});    } catch (Throwable e) {        e.printStackTrace();    }}public static String get(String prop, String defaultvalue) {    String value = defaultvalue;    try {        if (null == get) {            synchronized (PropertyUtils.class) {                if (null == get) {                    Class<?> cls = Class.forName("android.os.SystemProperties");                    get = cls.getDeclaredMethod("get", new Class<?>[]{String.class, String.class});                }            }        }        value = (String) (get.invoke(null, new Object[]{prop, defaultvalue}));    } catch (Throwable e) {        e.printStackTrace();    }    return value;}

}

提取方式
String mPropertyUtils = PropertyUtils.get(“gsm.serial”, “”);

0 0
原创粉丝点击