原创内容,转载请注明原文网址:http://homeqin.cn/a/wenzhangboke/jishutiandi/Android/2019/0615/542.html
	做运用时良多时候都得获取到每个建筑的机械码
	Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID)
	复制代码
	大概
	全部的建筑都能够回笼一个TelephonyManager.getDeviceId()
	全部的GSM建筑能够回笼一个TelephonyManager.getSimSerialNumber()
	全部的CDMA 建筑对于 getSimSerialNumber() 却回笼一个空值!
	全部增加有google账户的建筑能够回笼一个 ANDROID_ID
	全部的CDMA建筑对于 ANDROID_ID 和 TelephonyManager.getDeviceId() 回笼相像的值(只有在配置时增加了google账户) 
	正常环境下,你想得到建筑的唯一序号, TelephonyManager.getDeviceId() 就充足了。
	但会暴露DeviceID,最好把这些id加密。加密后的序号仍旧能够唯一的识别该建筑,
	比方,运用 String.hashCode() ,连结UUID:
	final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
	final String tmDevice, tmSerial, tmPhone, androidId;
	tmDevice = "" + tm.getDeviceId();
	tmSerial = "" + tm.getSimSerialNumber();
	androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
	UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());
	String uniqueId = deviceUuid.toString();
	复制代码
	末了的deviceID不妨这样的后果: 00000000-54b3-e7c7-0000-000046bffd97
上篇:上一篇:Android 8.0 启动service error IllegalStateException: Not al
下篇:下一篇:在fragment中援用ListView

