public class SystemPropertiesInvoke {
private static final String TAG = “SystemPropertiesInvoke”;
private static Method getLongMethod = null;
private static Method getBooleanMethod = null;

public static long getLong(final String key, final long def) {    try {        if (getLongMethod == null) {            getLongMethod = Class.forName("android.os.SystemProperties")                    .getMethod("getLong", String.class, long.class);        }        return ((Long) getLongMethod.invoke(null, key, def)).longValue();    } catch (Exception e) {        Log.e(TAG, "Platform error: " + e.toString());        return def;    }}public static boolean getBoolean(final String key, final boolean def) {    try {        if (getBooleanMethod == null) {            getBooleanMethod = Class.forName("android.os.SystemProperties")                    .getMethod("getBoolean", String.class,boolean.class);        }

return (Boolean)getBooleanMethod.invoke(null, key, def);
} catch (Exception e) {
Log.e(TAG, “Platform error: ” + e.toString());
return def;
}
}

public static String getString(final String key, final String def) {    try {        if (getBooleanMethod == null) {            getBooleanMethod = Class.forName("android.os.SystemProperties")                    .getMethod("getString", String.class,boolean.class);        }return (String)getBooleanMethod.invoke(null, key, def);    } catch (Exception e) {        Log.e(TAG, "Platform error: " + e.toString());        return def;    }}

}

调用方式
String serial = SystemPropertiesInvoke.getString(“gsm.serial”, “”);
Log.i(“TAG”, “serial==========” + serial);
请求权限




更多相关文章

  1. Android 应用获取通知栏权限
  2. Android的权限机制之—— “沙箱”机制sharedUserId跟签名
  3. 【Android UI】Android开发之View的几种布局方式及实践
  4. android的内存管理方式
  5. Android Manifest.permission权限
  6. Android图文混排实现方式详解
  7. Android 系统下模拟触点击的功能与权限

随机推荐

  1. 某技术大牛的帖子(android项目总结)
  2. 常见Android Native崩溃及错误原因
  3. Forge模型转换和网页浏览在Android上的实
  4. Android 自定义AlignTextView 完美解决原
  5. 近百个Android开发教程和资料收集整理打
  6. 基于Google Map API的android地图开发
  7. 转:RTC搭建android下三层应用程序访问服务
  8. 横竖屏切换时候activity的生命周期?
  9. Android Preference使用
  10. Android(安卓)SQlite数据库的使用(一)-一学