Last active
August 9, 2016 05:19
-
-
Save zhangyuchi/b61b30503a53a06a47ede17fbf0db69b to your computer and use it in GitHub Desktop.
获取设备唯一id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static AccountInfo getAccInfo(Context context, String jid) { | |
synchronized (acclock) { | |
if (AccInfo == null) { | |
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); | |
final String tmDevice, tmSerial, androidId; | |
tmDevice = "" + tm.getDeviceId(); | |
tmSerial = "" + tm.getSimSerialNumber(); | |
androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); | |
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); | |
String deviceId = "fakedeviceid-" + deviceUuid.toString(); | |
AccInfo = new AccountInfo(jid, jid, deviceId, null); | |
} | |
} | |
return AccInfo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment