android7.0关于TelephonyManager.getDeviceId()返回null的问题
2024-10-08 15:28:50
在android7.0的系统下发现TelephonyManager.getDeviceId()在权限允许的情况下取得返回值也为null,解决方法如下:
public static String getDeviceId(Context context) {
String id;
//android.telephony.TelephonyManager
TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (mTelephony.getDeviceId() != null) {
id = mTelephony.getDeviceId();
} else {
//android.provider.Settings;
id = Settings.Secure.getString(context.getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
}
return id;
}
相关资料地址:http://stackoverflow.com/questions/3802644/will-telephonymanger-getdeviceid-return-device-id-for-tablets-like-galaxy-tab
最新文章
- 前端构建大法 Gulp 系列 (二):为什么选择gulp
- Redis入门指南(第2版) Redis设计思路学习与总结
- ubuntu16.04中将python3设置为默认
- 【代码笔记】iOS-浮点数处理并去掉多余的0
- Eclipse Android HH and theme
- iOS - 网络 - NSURLSession
- C++常用库函数
- ubuntu升级php版本
- CYQ.Data V5 分布式自动化缓存设计介绍(二)
- VMware虚拟机安装教程
- 关于JS的原型与继承笔记
- RDKIT+postgresql做化合物数据存储与查找
- 目标检测中的mAP
- 【BZOJ1497】【NOI2006】最大获利
- ubuntu 安装时分辨率太小 导致无法继续安装
- AngularJS之过滤器
- 【LOJ】#2306. 「NOI2017」蔬菜
- Linux同步网络时间
- python 获取函数调用者
- 架构设计--用户端全http参数接口详细说明v1