第一种:SIM卡唯一标识 + DEVICE_ID(根据不同的手机设备返回IMEI,MEID或者ESN码)+androidId
这种方式获取的UUID是唯一不可变的,但是仅适用于手机中有SIM卡的情况。
private String getMyUUID(){
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.h