android 獲取手機唯一識別碼
//如果獲取不到imsi號,就拼接其它資訊獲取唯一碼:
結論是,依然有部分手機獲取不到。
final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
String uuid = tm.getSubscriberId();
if(CommonUtil.isEmpty(uuid)){
uuid = getMyUUID(tm);
}
//UUID+裝置號序列號 唯一識別碼(不可變)
private String getMyUUID(TelephonyManager tm){
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();
Log.d("debug","uuid="+uniqueId);
return uniqueId;
}
getNativePhoneNumber獲取的手機號
DeviceId(IMEI)手機 國際移動使用者識別碼
NetworkOperator 移動運營商編號
NetworkOperatorName 移動運營商名稱
SimSerialNumber SimOperator SimCountryIso SimSerialNumber SubscriberId(IMSI) 關於手機SIM卡的一些詳細資訊。