如何从字符串中的Andr​​oid创建UUID [英] How to create UUID from string in android

查看:183
本文介绍了如何从字符串中的Andr​​oid创建UUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我扫描低能量蓝牙特定服务的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()

这篇关于如何从字符串中的Andr​​oid创建UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆