android获取设备的唯一编号,获取Android唯一设备号

news/2024/7/24 10:52:55 标签: android获取设备的唯一编号

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); 请求权限


http://www.niftyadmin.cn/n/497604.html

相关文章

【数据结构与算法】复杂度分析

一、数据结构和算法解决的是“快”和“省”的问题,即如何让代码运行得更快,如何更省存储空间。所以「执行效率」是算法一个非常重要的考量指标,如何衡量编写的算法代码的执行效率?时间和空间复杂度分析。 换句话说:时间…

【Vue】动态路由的配置

通过 /detail/:id 的形式,可以创建一个动态路由。 export default new Router({routes: [{path: /detail/:id,name: Detail,component: Detail}] })

魅族Android10内测招募答案,魅族flyme9内测招募答案,魅族16系列flyme9内测招募题目答案免费分享预约 v1.0-手游汇...

魅族flyme9内测招募答案,今天开启的内测,对于新用户们需要完成答题申请,小编在这里为大家更新一些有用的题目和答案,对于您的申请也是有一定帮助的哦,希望您可以获得内测资格。flyme9特色:1.这个版本的更新…

【Safari】如何利用Safari浏览器,调试移动端的页面bug

作为一名前端开发,比较苦恼的是,在pc端用手机模拟器测试没有问题,在手机上却死活不行。遇到这种问题,如何是好? Safari设置 Safari偏好设置 -> 高级,勾选“在菜单中显示开发菜单”, iPhone设…

signature=26c5b2f6d29f4b312a83306be08132e1,modbus 查表法

CRC简单函数如下:unsigned short CRC16(puchMsg, usDataLen)unsigned char *puchMsg ; /* 要进行CRC校验的消息 */unsigned short usDataLen ; /* 消息中字节数 */{unsigned char uchCRCHi 0xFF ; /* 高CRC字节初始化 */unsigned char uchCRCLo 0xFF ; /* 低CRC 字…

【input】如何设置input标签不可编辑(亲测好使)

<input type"text" placeholder"请输入" readonly"readonly" unselectable"on"/> 提示&#xff1a;设置了 input 不显示光标&#xff0c;但当点击 input 时&#xff0c;仍会执行 focus( ) 方法。

【vconsole】H5页面控制台,也被称为移动端调试神器

github地址 &#xff1a;GitHub - Tencent/vConsole: A lightweight, extendable front-end developer tool for mobile web page. vconsole 是腾讯开发的一款针对手机网页的前端开发者调试插件&#xff0c;可以直接在手机上查看 console 日志、网络请求、页面 element 结构、C…

【input】当输入缓存数据时,input会自带背景颜色(亲测有效)

解决方案&#xff1a; input:-webkit-autofill { -webkit-box-shadow: 0 0 0 1000px white inset !important; }加上上面这段代码&#xff0c;即可解决这个bug。