如何从字符串中的Andr​​oid创建UUID字符串、Andr、UUID、oid

2023-09-08 08:48:46 作者:不负初心

在我的应用程序,我扫描低能量蓝牙特定服务的UUID 2415 。要转换的字符串2415到UUID我使用 UUID serviceUUID = UUID.fromString(2415); 但在这行出现异常抛出:IllegalArgumentException:无效的UUID 2415

请帮我在这方面,我将b非常感谢在这方面。先谢谢了。

解决方案

使用类 UUID

这样的一个例子:

  UUID.randomUUID()的toString()
 

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.

解决方案

Using the class UUID

An example like this:

 UUID.randomUUID().toString()