List of usage examples for java.util UUID UUID
public UUID(long mostSigBits, long leastSigBits)
From source file:Main.java
/** * get a unique hash of the device./*from w w w. j a v a 2 s .c o m*/ * * @return a unique hash of the device. */ public static String getDeviceId(Context ctx) { if (ctx == null) { return null; } String androidId = "" + android.provider.Settings.Secure.getString( ctx.getApplicationContext().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); String deviceName = getDeviceName(); UUID deviceUuid = new UUID(androidId.hashCode(), (long) deviceName.hashCode() << 32 | deviceName.hashCode()); String deviceId = deviceUuid.toString().replace("-", ""); return deviceId; }
From source file:Main.java
public static String getDeviceId(Context context) { if (deviceId == null) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String tmDevice, tmSerial, tmPhone, 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()); deviceId = deviceUuid.toString(); System.err.println(deviceId); }// w w w .j av a2s. c om return deviceId; }
From source file:Main.java
private static String generateDeviceUniqueIdentifier(Context context) { final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); final String tmDevice = "" + tm.getDeviceId(); final String tmSerial = "" + tm.getSimSerialNumber(); final String androidId = "" + Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); final String packageBasedAndroidId = context.getPackageName() + androidId; UUID deviceUuid = new UUID(packageBasedAndroidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); return deviceUuid.toString(); }
From source file:Main.java
public static String getDeviceUUID(Context context) { @SuppressWarnings("static-access") final TelephonyManager tm = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE); final String tmDevice, tmSerial, tmPhone, 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 uniqueId = deviceUuid.toString(); Log.d("debug", "uuid=" + uniqueId); return uniqueId; }
From source file:Main.java
public static synchronized UUID getOmnishareTaUuid() { long clockSeqAndNode = strToLong(new String("OMNISHAR")); UUID TA_CONN_TEST_UUID = new UUID(0x1234567887654321L, clockSeqAndNode); return TA_CONN_TEST_UUID; }
From source file:Main.java
/** * Converts the given byte array, which is expected to contain the UUID, into a UUID instance. * * @param byteArray The byte array containing the UUID. * @return A newly created UUID instance or null in case of a failure. *///from w w w . j av a2 s .com public static UUID byteArrayToUuid(byte[] byteArray) { if (byteArray != null && byteArray.length >= UUID_LENGTH_IN_BYTES) { ByteBuffer byteBuffer = ByteBuffer.wrap(byteArray); long mostSignificantBits = byteBuffer.getLong(); long leastSignificantBits = byteBuffer.getLong(); return new UUID(mostSignificantBits, leastSignificantBits); } return null; }
From source file:Main.java
public static String get_device_id(Context ctx) { final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); String tmDevice = ""; String tmSerial = null;// ww w .j av a 2 s. c o m String androidId = null; try { tmDevice = "" + tm.getDeviceId(); } catch (Exception ex) { } try { tmSerial = "" + tm.getSimSerialNumber(); } catch (Exception ex) { } try { androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); } catch (Exception ex) { } try { UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); String deviceId = deviceUuid.toString(); MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(deviceId.getBytes()); byte byteData[] = md.digest(); //convert the byte to hex format method 1 StringBuffer sb = new StringBuffer(); for (int i = 0; i < byteData.length; i++) { sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1)); } deviceId = sb.toString(); return deviceId; } catch (Exception ex) { } return "nodeviceid"; }
From source file:com.hengyi.japp.tools.UuidUtils.java
public static String decodeBase64Uuid(String compressedUuid) { byte[] byUuid = Base64.decodeBase64(compressedUuid); ByteBuffer bb = ByteBuffer.wrap(byUuid); UUID uuid = new UUID(bb.getLong(), bb.getLong()); return uuid.toString(); }
From source file:Main.java
public static String getPsuedoUniqueID() { String devIDShort = "35" + (Build.BOARD.length() % 10) + (Build.BRAND.length() % 10); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { devIDShort += (Build.SUPPORTED_ABIS[0].length() % 10); } else {//from w ww . j av a 2 s . c o m devIDShort += (Build.CPU_ABI.length() % 10); } devIDShort += (Build.DEVICE.length() % 10) + (Build.MANUFACTURER.length() % 10) + (Build.MODEL.length() % 10) + (Build.PRODUCT.length() % 10); String serial; try { serial = Build.class.getField("SERIAL").get(null).toString(); return new UUID(devIDShort.hashCode(), serial.hashCode()).toString(); } catch (Exception e) { serial = "ESYDV000"; } return new UUID(devIDShort.hashCode(), serial.hashCode()).toString(); }
From source file:com.scf.utils.UUIDUtilies.java
public static String decodeBase64Uuid(String compressedUuid) { byte[] byUuid = Base64.decodeBase64(compressedUuid); ByteBuffer bb = ByteBuffer.wrap(byUuid); UUID uuid = new UUID(bb.getLong(), bb.getLong()); return uuid.toString(); }