android手机唯一识别码
2015-09-23 17:39
806 查看
// http://blog.csdn.net/billpig/article/details/6728573 public UUID DeviceUuidBuild(Context context) { synchronized (this) { if( uuid == null) { final SharedPreferences prefs = context.getSharedPreferences( PREFS_FILE, 0); final String id = prefs.getString(PREFS_DEVICE_ID, null ); if (id != null) { uuid = UUID.fromString(id); } else { final String androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); try { if (!"9774d56d682e549c".equals(androidId)) //在主流厂商生产的设备上,有一个很经常的bug,就是每个设备都会产生相同的ANDROID_ID:9774d56d682e549c { uuid = UUID.nameUUIDFromBytes(androidId.getBytes("utf8")); } else { final String deviceId = ((TelephonyManager) context.getSystemService( Context.TELEPHONY_SERVICE )).getDeviceId(); uuid = deviceId != null ? UUID.nameUUIDFromBytes(deviceId.getBytes("utf8")) : UUID.randomUUID(); } } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } prefs.edit().putString(PREFS_DEVICE_ID, uuid.toString() ).commit(); } } } return uuid; }
相关文章推荐
- Android子线程中处理吐司的情况
- android AlarmManager采用
- Android Socket编程报错android.os.NetworkOnMainThreadException
- Android Studio快捷键[整理]
- Android进程优先级
- [Android一千零一个] android.content.ActivityNotFoundException: No Activity found to handle Intent
- 【转载】android中APK包的安装以及adb命令的使用
- 优秀Android开源项目大全
- android入门及晋级
- Android开发总结笔记 TextView(文本框) 1-1-6
- android中扩展View类的背景设置
- android 应用程序入口
- Android 获取ROOT权限原理解析
- 【Android开源项目解析】RecyclerView侧滑删除粒子效果实现——初探Android开源粒子库 Leonids
- Android SDK开发包国内下载地址
- Android Studio + NDK 之 Hello Word
- Android版本和API Level对应关系
- android编译时Failure [INSTALL_FAILED_OLDER_SDK]
- Android Studio常用的40个快捷键
- 【MDCC技术大咖秀】Android内存优化之OOM