0

我目前可以fetchUuidsWithSdp使用远程设备。getUuids不工作,不知道为什么)

但是我怎么能得到我自己的安卓设备的 UUID 呢?

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

我发现情况并非总是如此!我想测试一下。。

4

2 回答 2

1

嘿有点晚,但我发现最好的方法是做这样的事情。对于生产代码,我不是最好的主意,但对于测试它还不错。

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

希望这可以帮助

于 2014-06-16T18:07:43.990 回答
0
 TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
 String uuid = tManager.getDeviceId();
//or
UUID.nameUUIDFromBytes(tManager.getDeviceId().getBytes("utf8"))
于 2013-09-25T10:47:03.450 回答