UUID和GUID问题 [英] Problem with UUID and GUID

查看:135
本文介绍了UUID和GUID问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请不要将其标记为重复项.我浏览了有关该主题的所有帖子,但无法解决我的问题.

Please don't mark this as duplicate. I have gone through all posts on this topic but couldn't solve my problem.

我在J2ME中有一个应用程序,用于搜索具有特定UUID的蓝牙服务:

I have an application in J2ME that searches for bluetooth services with a particular UUID:

UUID[] uuidSet = { new UID("100000",true) };
int[] attrSet = {0x0100, 0x0003, 0x0004};
int transID = agent.searchServices(attrSet,uuidSet,remoteDevice,this);

我在VB.NET中使用32feet.NET库创建了一个桌面应用程序,该库使用特定的GUID创建了新的蓝牙服务.

I have a desktop application in VB.NET using 32feet.NET library that creates a new bluetooth service with a particular GUID.

Sub startBluetoothListener()
    Dim lsnr As New BluetoothListener(MyConsts.MyServiceUuid, record)
    lsnr.Start()
    Dim conn As New BluetoothClient
    Dim peerStream As Stream            
End Sub

Class MyConsts
Public Shared ReadOnly MyServiceUuid As Guid _
  = New Guid("{7dc53df5-703e-49b3-8670-b1c468f47f1f}")
End Class

现在按照规则,为了同时起作用,两个GUID/UUID应该匹配.但是,在.NET中,GUID表示为十六进制字符串,而在JAVA中则不同.我在Google上搜索了很多有关如何同步J2ME和.NET GUID/UUID的信息,但未能成功.

Now as per rules, in order to function both GUID/UUID should match. However in .NET the GUID is represented as a hexadecimal string and in JAVA it's different. I googled a lot about how to sync the J2ME and .NET GUID/UUID but could not succeed.

推荐答案

我已经阅读了UUID的j2me实现的源代码,它似乎只是表明您省略了花括号和连字符,即使用了:

I've read the source for the j2me implementation of UUID, and it simply seems to indicate that you omit the braces and the hyphens i.e. use:

new UUID("7dc53df5703e49b38670b1c468f47f1f", false)

如果您使用true参数,则它将使用简短的UUID(即8个字符长)

if you use the true parameter, it expects a short-form UUID (i.e. 8 characters long)

我最初的答案是基于J2SE实现的,即:

My original answer was based on the J2SE implementation, viz:

不是来自字符串的UUID的构造函数:

isn't the constructor for a UUID from a string:

UUID aUUID = UUID.fromString(")

UUID aUUID = UUID.fromString("")

字符串在哪里:

7dc53df5-703e-49b3-8670-b1c468f47f1f

7dc53df5-703e-49b3-8670-b1c468f47f1f

对于您的UUID(即从Guid字符串中删除开头的"{"和结尾的}")

in the case of your UUID (i.e. remove the leading '{' and trailing '}' from the Guid string)

这篇关于UUID和GUID问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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