在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

最新文章

  1. 前端构建大法 Gulp 系列 (二):为什么选择gulp
  2. Redis入门指南(第2版) Redis设计思路学习与总结
  3. ubuntu16.04中将python3设置为默认
  4. 【代码笔记】iOS-浮点数处理并去掉多余的0
  5. Eclipse Android HH and theme
  6. iOS - 网络 - NSURLSession
  7. C++常用库函数
  8. ubuntu升级php版本
  9. CYQ.Data V5 分布式自动化缓存设计介绍(二)
  10. VMware虚拟机安装教程
  11. 关于JS的原型与继承笔记
  12. RDKIT+postgresql做化合物数据存储与查找
  13. 目标检测中的mAP
  14. 【BZOJ1497】【NOI2006】最大获利
  15. ubuntu 安装时分辨率太小 导致无法继续安装
  16. AngularJS之过滤器
  17. 【LOJ】#2306. 「NOI2017」蔬菜
  18. Linux同步网络时间
  19. python 获取函数调用者
  20. 架构设计--用户端全http参数接口详细说明v1

热门文章

  1. Dubbo教程:入门到实战
  2. docker aufs存储驱动文件系统
  3. VBA 学习笔记 - 输入框
  4. Spring Boot 缓存应用 Memcached 入门教程
  5. redis基本操作,基于StringRedisTemplate,存储,取值,设置超时时间,获取超时时间,插入list操作
  6. JAXB - java xml解析
  7. idea中scala项目补全变量、添加打印语句的小技巧
  8. mysql之指定为definer的用户不存在
  9. 解决:使用 swiper 自动轮播图片,当拖动过 swiper 内的内容时,导致不继续自动轮播
  10. WEB - JSONP