我怎么能得到我自己的Android设备的蓝牙UUID?

时间:2013-01-02 14:52:45

标签: android bluetooth uuid sdp

我目前可以使用远程设备fetchUuidsWithSdpgetUuids不起作用,不确定原因)

但我怎么能得到我自己的Android设备的UUID?

假设,当我在服务器套接字上成功执行accept()时,注册的UUID 必须包含我建立的UUID在使用此命令listenUsingInsecureRfcommWithServiceRecord

创建服务器套接字时

我发现这是总是如此!我想测试一下..

2 个答案:

答案 0 :(得分:1)

Hey a Little Late但我找到的最好的方法是做这样的事情。我不是生产代码最好的想法,但测试它并不坏。

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 
Method getUUIDsMethod = BluetoothAdapter.class.getDeclaredMethod("getUuids", null);
ParcelUuid[] dUUIDs = (ParcelUuid[]) getUUIDsMethod.invoke(mBluetoothAdapter, null);

希望这有帮助

答案 1 :(得分:0)

 TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
 String uuid = tManager.getDeviceId();
//or
UUID.nameUUIDFromBytes(tManager.getDeviceId().getBytes("utf8"))