6

If I have a Android phone which is already connected with a bluetooth headset (paired and connected) to it. How I can get information about that specific headset.

Using getBondedDevices() method I get list of all paired devices..I need information about CONNECTED device only.

I can not wait for broadcast receiver to check status, because I need this information at the start of my application. So please suggest is there any way to get this information without waiting for broadcast.

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Deeps
  • 61
  • 1
  • 1
  • 3
  • See my answer at http://stackoverflow.com/questions/14991158/using-the-android-recognizerintent-with-a-bluetooth-headset/14993590#14993590 – Hoan Nguyen Mar 08 '13 at 07:40

3 Answers3

0

Check this out to see if headset is connected (ICS only):

    public boolean isVoiceConnected()
    {
        boolean retval = true;
        try {
            retval = BluetoothAdapter.getDefaultAdapter().getProfileConnectionState(android.bluetooth.BluetoothProfile.HEADSET) != android.bluetooth.BluetoothProfile.STATE_DISCONNECTED;

        } catch (Exception exc) {
            // nothing to do
        }
        return retval;
    }
Yossi
  • 1,226
  • 1
  • 16
  • 31
0

You can do this through the IBluetoothA2dp interface in API 11 and up. Some more info on there is here: Android connect to a paired bluetooth headset

Here is a great resource to see the difference in what is available to this interface between API 10 and 11 where it changed quite a bit. http://grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/bluetooth/BluetoothA2dp.java/?v=diff&id2=2.2_r1.1

Hope that helps.

Community
  • 1
  • 1
jroal
  • 547
  • 6
  • 16
0

You can use the getConnectedDevices for the HEADSET Profile to get the device to which it is connected.

Dennis Mathews
  • 6,897
  • 2
  • 26
  • 39