Android Bluetooth: Get UUIDs of discovered devices

后端 未结 6 1632
悲哀的现实
悲哀的现实 2020-12-01 08:15

As I\'m currently working on a little bluetooth library for Android, I\'m trying to get all the service uuids of the devices I discovered in my surrounding.

When my

6条回答
  •  春和景丽
    2020-12-01 08:45

    Below worked for me to fetch the records from the remote device

    -0-
    registerReceiver(..,
                    new IntentFilter(BluetoothDevice.ACTION_UUID));
    

    -1- device.fetchUuidsWithSdp();

    -2-from within the broadcase receiver

       if (BluetoothDevice.ACTION_UUID.equals(action)) {
                            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                            Parcelable[] uuids = intent.getParcelableArrayExtra(BluetoothDevice.EXTRA_UUID);
                            for (Parcelable ep : uuids) {
                                Utilities.print("UUID records : "+ ep.toString());
                            }
                        }
    

    You can also fetch the offline cached UUID records with

     BluetoothDevice.getUuids();
    

提交回复
热议问题