Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Currently connected bluetooth device android

I can able to see two states in Bluetooth device in Android. 1. Paired 2. Connected. -
I am trying to get currently connected Bluetooth device in Android. But I am getting only paired device list from adapter.getBondedDevices(); I need currently connected device. How can i get this. Please someone help me to achieve this. Thanks in advance.

like image 997
Ria Avatar asked Oct 28 '15 05:10

Ria


People also ask

How do I see what devices are connected to my Bluetooth?

Swipe down from the top of the screen. Touch and hold Bluetooth . If your accessory is listed under "Available media devices," next to your device's name, tap Settings . If no accessories are listed under "Previously connected devices," tap See all.

Can someone connect to my Bluetooth without me knowing?

Can someone connect to my Bluetooth without me knowing? Theoretically, anyone can connect to your Bluetooth and gain unauthorized access to your device if the visibility of your Bluetooth device is on.


1 Answers

That's pretty straight forward. Android BluetoothManager have method of

getConnectedDevices()

Implementation like:

BluetoothManager manager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE);
    List<BluetoothDevice> connected = manager.getConnectedDevices(GATT);
    Log.i("Connected Devices: ", connected.size()+"");

If you want more details about connected devices then you can use the above list method put it into for loop and get the inner details of each Bluetooth device which are connected.

Logs:

12-20 18:04:09.679 14933-14933/com.salman.dleague.blescanning I/Connected Devices:: 2

Hope its helpful :)

like image 173
Salman Naseem Avatar answered Oct 17 '22 19:10

Salman Naseem