[Android][工具类]PropertisUtils

2018-06-26  本文已影响31人  子木同

package com.cw.testapp.utils;

import android.util.VendorUtils;

import com.cw.testapp.misc.Constants;
import com.gzgd.log.LogUtils;

import java.lang.reflect.Method;

/**

public static String setProperties(String key, String value) {
    String Value = null;
    Class<?> SystemPropertiesClass = null;
    Method method = null;

    try {

        SystemPropertiesClass = Class
                .forName("android.os.SystemProperties");
        Class<?> getType[] = new Class[2];
        getType[0] = String.class;
        getType[1] = String.class;
        method = SystemPropertiesClass.getMethod("set", getType);

        Object arglist[] = new Object[2];
        arglist[0] = key;
        arglist[1] = value;

        Object receiver = new Object();

        Object returnvalue = method.invoke(receiver, arglist);
        if (receiver != null) {
            Value = (String) returnvalue;
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    return Value;
}

}

上一篇 下一篇

猜你喜欢

热点阅读