Java UUID – Using Arbitrary Strings as UUID

androidjavaprogramming practicesuuid

I found the tutorial of client (android) and server (pc) bluetooth tutorial from here.

But my question is about the UUID.

Is that okay if we define it randomly without the proper format? Because I heard UUID is generally for ID for each devices just like IP address used right?

For example like this, instead of the following code:

UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");

I define my own UUID

UUID.fromString("myDeviceName009");

Is it okay? I mean is it if i tested on both android device using the above code, they could communicate each other?

Best Answer

No. A UUID has a particular, standardised format.

From the wiki article on the subject:

In its canonical form, a UUID is represented by 32 lowercase hexadecimal digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four hyphens).