How to create UUID from string in android

user3056760 picture user3056760 · Dec 2, 2013 · Viewed 52.9k times · Source

In my app, I scan low energy Bluetooth for specific service uuid 2415. To convert the string 2415 into uuid I am using UUID serviceUUID = UUID.fromString("2415"); but at this line exception arises IllegalArgumentException: Invalid UUID 2415.

Please help me in this respect I would b very thankful to in this regard. Thanks in advance.

Answer

Alécio Carvalho picture Alécio Carvalho · Jun 3, 2014

Using the class UUID

An example like this:

 UUID.randomUUID().toString()