2013-01-02 35 views
0

我目前可以fetchUuidsWithSdp远程设备。 getUuids不工作,不知道为什么)我怎么能得到我自己的Android设备的蓝牙UUID?

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

这是应该,当我成功执行accept()在一个服务器套接字注册的UUID 必须包括我在创建服务器插座与此命令listenUsingInsecureRfcommWithServiceRecord

建立的UUID我发现了这个是不是总是这样!我想测试它..

+0

你有没有得到你的答案,我也想找到我自己的设备的UUID。 –

回答

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

这个问题与蓝牙有关,而不是电话:) –

1

嘿一点晚了,但我发现最好的方法是做这样的事情。我不是生产代码的最好主意,而是测试它并不坏。

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

希望这有助于