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-04-30 11:05:11 发布
本文介绍了如何通过反射技术在三方应用中访问和修改Android系统的SystemProperties,详细讲解了相关步骤和注意事项。
摘要由CSDN通过智能技术生成