获取特定蓝牙设备的UUID

时间:2017-03-07 07:18:34

标签: android bluetooth uuid

我正在使用以下代码段来获取该范围内设备的UUID。现在我只需要为我选择的设备获取UUID(服务)。我应该如何传递蓝牙设备的名称,以便我只为该设备获得服务。

if(BluetoothDevice.ACTION_UUID.equals(action)) 
{
BluetoothDevice device =intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Parcelable[] uuidExtra = intent.getParcelableArrayExtra(BluetoothDevice.EXTRA_UUID);
for (int i = 0; i < uuidExtra.length; i++) {
String abc=uuidExtra[i].toString());
}
}
else if(BluetoothDevice.ACTION_UUID.equals(action)){
            Iterator<BluetoothDevice> itr = mDeviceList.iterator();
            while (itr.hasNext()) {
                // Get Services for paired devices
                BluetoothDevice device = itr.next();
                showToast("\nGetting Services for " + device.getName() + ", " + device);
                if(!device.fetchUuidsWithSdp()) {
                    showToast("\nSDP Failed for " + device.getName());
                }

            }
        }

0 个答案:

没有答案