DS009
DS009

Reputation: 179

How to get list of connected peripherals in an android application (not android things)

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

Upvotes: 2

Views: 1254

Answers (1)

Code Demon
Code Demon

Reputation: 1334

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

Upvotes: 1

Related Questions