Application Generates UUID?

I think I need to understand more how UUID works. I am working on an application and I want the application to generate a UUID when the application is first loaded and started. Is it possible to generate a new uuid every time the user downloads the app? and maybe if there is another site other than android developer where I can understand or see examples of who is using uuid can someone publish? Thank.


source to share

2 answers

Here is the code to generate the UUID:

String android_id = Secure.getString(getApplicationContext()
            .getContentResolver(), Secure.ANDROID_ID);
    Log.i("System out", "android_id : " + android_id);

    final TelephonyManager tm = (TelephonyManager) getBaseContext()

    final String tmDevice, tmSerial, androidId;
    tmDevice = "" + tm.getDeviceId();
    Log.i("System out", "tmDevice : " + tmDevice);
    tmSerial = "" + tm.getSimSerialNumber();
    Log.i("System out", "tmSerial : " + tmSerial);
    androidId = ""
            + android.provider.Settings.Secure.getString(

    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice
            .hashCode() << 32)
            | tmSerial.hashCode());
    String UUID = deviceUuid.toString();
    Log.i("System out", "UUID : " + UUID);




UUID uuid = UUID.randomUUID();


This should generate a random UUID for you so you can use whatever you want.



All Articles