简体   繁体   English

如何从我的Android设备中发现UUID?

[英]How can I discover the UUID from my android device?

I'm trying to make an application that sends messages via Bluetooth. 我正在尝试制作一个通过蓝牙发送消息的应用程序。 But when i try to connect my device with others an error occurs (my socket fails to make the connection and an exception is thrown. I honestly believe it's because of my UUID. I can't seem to find how to use it, so I have definied a static, already known value, that I found on the internet for my UUID. PS: I'm working with Android 2.3.7 (API 10), so the method getUuid() does not work. 但是,当我尝试将设备与其他设备连接时,会发生错误(我的套接字无法建立连接,并引发了异常。老实说,这是因为我的UUID。我似乎找不到使用方法,所以我我在网上为UUID定义了一个已知的静态值PS:我正在使用Android 2.3.7(API 10),因此getUuid()方法不起作用。

For , android version < 3. So, try the code: 对于,Android版本<3。因此,请尝试代码:

Method method = phoneDevice.getClass().getMethod("getUuids", null);
ParcelUuid[] phoneUuids = (ParcelUuid[]) method.invoke(phoneDevice, null);

Hope it helps you.. 希望对您有帮助。

Ref : How do I get the UUID of a bluetooth device? 参考: 如何获取蓝牙设备的UUID?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM