3

below method provides the list of bluetooth bounded devices.

BluetoothAdapter blueToothAdapter = BluetoothAdapter.getDefaultAdapter();
Set<BluetoothDevice>pairedDevices = blueToothAdapter.getBondedDevices();

how can check whether this device currently connected or not?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • Until you unpair the devices it will be shown. Once the device is unpaired then it won't show. – Shriram Apr 08 '14 at 09:14
  • ok,i want to get the Paired devices that are available in the range. –  Apr 08 '14 at 09:23
  • check this link.http://digitalhacksblog.blogspot.in/2012/05/android-example-bluetooth-discover-and.html – Shriram Apr 08 '14 at 09:27

2 Answers2

3

The answer is that you can't. The Bonded list tells you which devices are paired, but not their connection status and there is no API provided to give you that information.

In practice you have two choices.

  1. Try to connect to each in turn and see how you go. This is a blocking operation, and quite slow.
  2. Monitor the relevant activities using Intent filters and maintain your own list. See How to programmatically tell if a Bluetooth device is connected? (Android 2.2) for details.

Sorry about that. Definitely one for a future enhancement.

Community
  • 1
  • 1
david.pfx
  • 10,520
  • 3
  • 30
  • 63
  • the device to which my device is connected if off his bluetooth then event not fire.if that device move away even then event not fire,then how i can make the list. –  Apr 08 '14 at 19:02
  • 1
    You would need a background service running all the time (if I understand your English correctly). – david.pfx Apr 08 '14 at 22:41
1

Check Here - > How to programmatically tell if a Bluetooth device is connected? (Android 2.2)

The first answer post did exactly what you want.

Good Luck!

Community
  • 1
  • 1
Thiago Souto
  • 761
  • 5
  • 13