Example usage for java.util UUID UUID

List of usage examples for java.util UUID UUID

Introduction

In this page you can find the example usage for java.util UUID UUID.

Prototype

public UUID(long mostSigBits, long leastSigBits) 

Source Link

Document

Constructs a new UUID using the specified data.

Usage

From source file:Main.java

public static void main(String arg[]) {
    System.out.println(new UUID(123456789L, 123456789L));
}

From source file:Main.java

public static UUID emptyGuid() {
    return new UUID(0, 0);
}

From source file:Main.java

public static boolean isGuidEmpty(UUID value) {
    return (new UUID(0L, 0L).equals(value));
}

From source file:Main.java

public static UUID toUUID(byte[] bytes) {
    ByteBuffer bb = ByteBuffer.wrap(bytes);
    long firstLong = bb.getLong();
    long secondLong = bb.getLong();
    return new UUID(firstLong, secondLong);
}

From source file:Main.java

public static UUID getUuidFromByteArrayBigEndian(byte[] bytes) {
    ByteBuffer bb = ByteBuffer.wrap(bytes);
    long high = bb.getLong();
    long low = bb.getLong();
    UUID uuid = new UUID(high, low);
    return uuid;//from w  ww . ja v  a2 s  . c  om
}

From source file:Main.java

public static UUID getUUID(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String uniqueId = tm.getDeviceId();
    UUID deviceUuid = new UUID(uniqueId.hashCode(), 64);
    return deviceUuid;
}

From source file:Main.java

public static UUID toUuid(long assignedNumber) {
    return new UUID((assignedNumber << 32) | 0x1000, leastSigBits);
}

From source file:Main.java

public static UUID toUuid(long assignedNumber) {
    return new UUID((assignedNumber << SIXTH_BITMASK) | PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM,
            leastSigBits);/*w  ww .  j a va2  s.c o m*/
}

From source file:Main.java

public static String bytesToUuid(byte[] bytes) {
    ByteBuffer bb = ByteBuffer.wrap(bytes);
    bb.order(ByteOrder.LITTLE_ENDIAN);

    long lsb = bb.getLong();
    long msb = bb.getLong();
    UUID uuid = new UUID(msb, lsb);
    return uuidToString(uuid);
}

From source file:Main.java

public static String getDeviceKey(Context ctx) {

    final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    final String tmDevice, tmSerial, androidId;
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "" + tm.getSimSerialNumber();
    androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(),
            android.provider.Settings.Secure.ANDROID_ID);
    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    return deviceUuid.toString();
}