public class GetSystemProperties {
private static Class<?> systemProperties() throws Exception {
return Class.forName("android.os.SystemProperties");
}
public static String get(String key) {
try {
final Class<?> SystemProperties = systemProperties();
return (String) SystemProperties.getMethod("get", new Class[]{
String.class})
.invoke(SystemProperties, key);
} catch (Exception e) {
return "";
}
}
public static String get(String key, String def) {
try {
final Class<?> SystemProperties = systemProperties();
return (String) SystemProperties.getMethod("get", new Class[]{
String.class, String.class})
.invoke(SystemProperties, key, def);
} catch (Exception e) {
return def;
}
}
public
三方应用如何使用反射获取SystemProperties
最新推荐文章于 2024-08-31 14:42:53 发布