2

我是 Android 开发的新手,并且正在处理获取连接到 android 设备的外围设备列表的要求。设备列表示例:外部扬声器、连接的显示器。

有没有办法获取外围设备列表?

注意:我不是在做 Android 的事情,因此不考虑PeripheralManager

4

1 回答 1

0

要获取 USB 连接设备列表,请参阅: https ://developer.android.com/guide/topics/connectivity/usb/host 要获取蓝牙设备列表,请参阅:gat

final BluetoothManager bluetoothManager = (BluetoothManager)getSystemService(Context.BLUETOOTH_SERVICE);
List<BluetoothDevice> gattServerConnectedDevices = bluetoothManager.getConnectedDevices(BluetoothProfile.GATT_SERVER);
for (BluetoothDevice device : gattServerConnectedDevices) {
Log.d("Tag", "Found connected device: " + device.getAddress());
}

非门见:https://developer.android.com/reference/android/bluetooth/BluetoothManager.html#getConnectedDevices(int)

对于 wifi 连接的设备,请参阅:https ://stackoverflow.com/a/21391836/8461344

对于外部显示,请参阅:https://stackoverflow.com/q/32498834/8461344

于 2020-07-14T09:42:08.373 回答