我需要了解API 8(2.2)或可能的2.3.3上的UUID。
据我了解的文档,这应该被允许:
phoneDevice = blueAdapter.getRemoteDevice(phoneAddress);
ParcelUuid[] phoneUuids = phoneDevice.getUuids(); // Won't compile
Eclipse给了我:
“对于类型BluetoothDevice,未定义方法getUuids()。”
但请参阅:
http://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#getUuids()
另外,我想知道如何在ParcelUuid []内部“打包” UUID。如果我设法到达那里,如何从parcelUuid []中检索UUID?在我看来,Android蓝牙的文档似乎很贫乏。
真是笑话!
现在,我尝试从 Intent 中获取它,但这也给出了:*“EXTRA_UUID无法解析或不是字段” *:
intent.getParcelableExtra(BluetoothDevice.EXTRA_UUID);
最佳答案
您必须使用反射来在Android版本
Method method = phoneDevice.getClass().getMethod("getUuids", null);
ParcelUuid[] phoneUuids = (ParcelUuid[]) method.invoke(phoneDevice, null);
关于android - 如何获得蓝牙设备的UUID?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9568084/