2

I am new to Android development and working on a requirement to get the list of peripherals connected to an android device. Example list of devices: external speaker, display monitors connected.

Is there a way to get the peripherals list?

Note: I am not working on Android things and hence not considering PeripheralManager

Boken
  • 4,825
  • 10
  • 32
  • 42
DS009
  • 169
  • 3
  • 5
  • 14
  • you can use PeripheralManager for getting list. try this link too https://codelabs.developers.google.com/codelabs/androidthings-peripherals/#5 – unzila Jul 09 '20 at 17:02
  • I've seen documentation for PeripheralManager, but I see that is for Android Things. My application is not an android things application, so looking for other options – DS009 Jul 09 '20 at 17:11
  • you can edit your question so we can understand that which type of list you want to get – unzila Jul 09 '20 at 17:14
  • Thank you, Edited! – DS009 Jul 09 '20 at 17:19

1 Answers1

1

To get a list of usb connected devices see: https://developer.android.com/guide/topics/connectivity/usb/host To get a list of bluetooth devices see : 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());
}

non gat see : https://developer.android.com/reference/android/bluetooth/BluetoothManager.html#getConnectedDevices(int)

for wifi connected devices see: https://stackoverflow.com/a/21391836/8461344

for external dispays see :https://stackoverflow.com/q/32498834/8461344

Code Demon
  • 1,256
  • 1
  • 9
  • 15
  • For USB https://stackoverflow.com/questions/40891108/how-to-get-list-of-usb-accessories-connected-to-android-device – Kevin Parker Jul 20 '20 at 20:39