Skip to content

Instantly share code, notes, and snippets.

@zhangyuchi
Last active August 9, 2016 05:19
Show Gist options
  • Save zhangyuchi/b61b30503a53a06a47ede17fbf0db69b to your computer and use it in GitHub Desktop.
Save zhangyuchi/b61b30503a53a06a47ede17fbf0db69b to your computer and use it in GitHub Desktop.
获取设备唯一id
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