Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#constants) \| [Inherited Constants](https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#inhconstants) \| [Methods](https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#pubmethods) \| [Protected Methods](https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#promethods) \| [Inherited Methods](https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#inhmethods)

# BluetoothHeadset

*** ** * ** ***


`
public

final

class
BluetoothHeadset
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/android/bluetooth/BluetoothProfile


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.bluetooth.BluetoothHeadset |

<br />

*** ** * ** ***

Public API for controlling the Bluetooth Headset Service. This includes both Bluetooth Headset
and Handsfree (v1.5) profiles.

BluetoothHeadset is a proxy object for controlling the Bluetooth Headset Service via IPC.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getProfileProxy(android.content.Context,%20android.bluetooth.BluetoothProfile.ServiceListener,%20int)` to get the BluetoothHeadset proxy object. Use
`https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#closeProfileProxy(int,%20android.bluetooth.BluetoothProfile)` to close the service connection.

Android only supports one connected Bluetooth Headset at a time. Each method is protected with
its appropriate permission.

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_AUDIO_STATE_CHANGED` Intent used to broadcast the change in the Audio Connection state of the HFP profile. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_CONNECTION_STATE_CHANGED` Intent used to broadcast the change in connection state of the Headset profile. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_VENDOR_SPECIFIC_HEADSET_EVENT` Intent used to broadcast that the headset has posted a vendor-specific event. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#AT_CMD_TYPE_ACTION` AT command type ACTION used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` For example, AT+CHUP. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#AT_CMD_TYPE_BASIC` AT command type BASIC used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` For example, ATD. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#AT_CMD_TYPE_READ` AT command type READ used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` For example, AT+VGM?. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#AT_CMD_TYPE_SET` AT command type SET used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` For example, AT+VGM=. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#AT_CMD_TYPE_TEST` AT command type TEST used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` For example, AT+VGM=?. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#CODEC_TYPE_CVSD` HFP codec type CVSD. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#CODEC_TYPE_LC3_SWB` HFP codec type LC3 SWB. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#CODEC_TYPE_MSBC` HFP codec type mSBC. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#CODEC_TYPE_UNSUPPORTED` HFP codec type is not supported or cannot be determined |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#CODEC_TYPE_VENDOR_SPECIFIC` HFP vendor specific codec Type |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_DISCONNECTED_REASON` Used as an int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_CONNECTION_STATE_CHANGED` intents for connection failure reasons. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS` A Parcelable String array extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_VENDOR_SPECIFIC_HEADSET_EVENT` intents that contains the arguments to the vendor-specific command. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD` A String extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_VENDOR_SPECIFIC_HEADSET_EVENT` intents that contains the name of the vendor-specific command. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` An int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_VENDOR_SPECIFIC_HEADSET_EVENT` intents that contains the AT command type of the vendor-specific command. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#STATE_AUDIO_CONNECTED` Headset state when SCO audio is connected. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#STATE_AUDIO_CONNECTING` Headset state when SCO audio is connecting. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#STATE_AUDIO_DISCONNECTED` Headset state when SCO audio is not connected. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#VENDOR_RESULT_CODE_COMMAND_ANDROID` A vendor-specific command for unsolicited result code. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY` The intent category to be used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_VENDOR_SPECIFIC_HEADSET_EVENT` for the companyId |

### Inherited constants

From interface `https://developer.android.com/reference/android/bluetooth/BluetoothProfile` `int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#A2DP`

Advanced Audio Distribution Profile (A2DP)


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#CSIP_SET_COORDINATOR`

Coordinated Set Identification Profile (CSIP) set coordinator


`https://developer.android.com/reference/java/lang/String` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_PREVIOUS_STATE`

Extra for the connection state intents of the individual profiles.


`https://developer.android.com/reference/java/lang/String` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_PROFILE`

Extra for the `https://developer.android.com/reference/android/bluetooth/BluetoothProfile` that the intent applies to.


`https://developer.android.com/reference/java/lang/String` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE`

Extra for the connection state intents of the individual profiles.


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#GATT`

Generic Attribute Profile (GATT)


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#GATT_SERVER`

Generic Attribute Profile (GATT) Server


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HAP_CLIENT`


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HEADSET`

Headset and Handsfree profile


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HEALTH`

*This constant was deprecated
in API level 29.
Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should
use Bluetooth Low Energy based solutions such as `https://developer.android.com/reference/android/bluetooth/BluetoothGatt`, `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#listenUsingL2capChannel()`, or `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#createL2capChannel(int)`*


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HEARING_AID`

Hearing Aid Device


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HID_DEVICE`

Human Interface Device (HID) Device


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#LE_AUDIO`

LE Audio Device


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#SAP`

SIM Access Profile (SAP)


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED`

The profile is in connected state


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTING`

The profile is in connecting state


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED`

The profile is in disconnected state


`int` `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTING`

The profile is in disconnecting state


| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#getCodecType(android.bluetooth.BluetoothDevice)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device) ` Get the codec type of the given HFP connected device. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/bluetooth/BluetoothDevice>` | ` https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#getConnectedDevices()() ` Get connected devices for this specific profile. For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`. |
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#getConnectionState(android.bluetooth.BluetoothDevice)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device) ` Get the current connection state of the profile For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/bluetooth/BluetoothDevice>` | ` https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#getDevicesMatchingConnectionStates(int[])(int[] states) ` Get a list of devices that match any of the given connection states. For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#isAudioConnected(android.bluetooth.BluetoothDevice)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device) ` Check if Bluetooth SCO audio is connected. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#isNoiseReductionSupported(android.bluetooth.BluetoothDevice)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device) ` Checks whether the headset supports some form of noise reduction. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#isVoiceRecognitionSupported(android.bluetooth.BluetoothDevice)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device) ` Checks whether the headset supports voice recognition. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#sendVendorSpecificResultCode(android.bluetooth.BluetoothDevice,%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, https://developer.android.com/reference/java/lang/String command, https://developer.android.com/reference/java/lang/String arg) ` Sends a vendor-specific unsolicited result code to the headset. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#startVoiceRecognition(android.bluetooth.BluetoothDevice)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device) ` Start Bluetooth voice recognition. |
| ` boolean` | ` https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#stopVoiceRecognition(android.bluetooth.BluetoothDevice)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device) ` Stop Bluetooth Voice Recognition mode, and shut down the Bluetooth audio path. |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


From interface `

https://developer.android.com/reference/android/bluetooth/BluetoothProfile

` `
abstract


https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/bluetooth/BluetoothDevice>` `
https://developer.android.com/reference/android/bluetooth/BluetoothProfile#getConnectedDevices()()
`

Get connected devices for this specific profile.


`
abstract


int` `
https://developer.android.com/reference/android/bluetooth/BluetoothProfile#getConnectionState(android.bluetooth.BluetoothDevice)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device)
`

Get the current connection state of the profile


`
abstract


https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/bluetooth/BluetoothDevice>` `
https://developer.android.com/reference/android/bluetooth/BluetoothProfile#getDevicesMatchingConnectionStates(int[])(int[] states)
`

Get a list of devices that match any of the given connection states.


## Constants

### ACTION_AUDIO_STATE_CHANGED

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_AUDIO_STATE_CHANGED
```

Intent used to broadcast the change in the Audio Connection state of the HFP profile.

This intent will have 3 extras:

- `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE` - The current state of the profile.
- `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_PREVIOUS_STATE`- The previous state of the profile.
- `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#EXTRA_DEVICE` - The remote device.

`https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE` or `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_PREVIOUS_STATE` can be any of `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#STATE_AUDIO_CONNECTED`, `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#STATE_AUDIO_DISCONNECTED`,.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

Constant Value:

"android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED"


### ACTION_CONNECTION_STATE_CHANGED

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_CONNECTION_STATE_CHANGED
```

Intent used to broadcast the change in connection state of the Headset profile.

This intent will have the following extras:

- `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE` - The current state of the profile.
- `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_PREVIOUS_STATE`- The previous state of the profile.
- `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#EXTRA_DEVICE` - The remote device.
- `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_DISCONNECTED_REASON` - A disconnection reason if moved from `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTING` to `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED`.
- `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#EXTRA_CLASS` - The class of the remote device, if available, when the new state is `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED`.
- `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#EXTRA_LE_APPEARANCE` - The LE appearance of the remote device, if available, when the new state is `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED`.

`https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE` or `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_PREVIOUS_STATE` can be any of `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED`, `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTING`, `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED`, `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTING`.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

Constant Value:

"android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED"


### ACTION_VENDOR_SPECIFIC_HEADSET_EVENT

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
```

Intent used to broadcast that the headset has posted a vendor-specific event.

This intent will have 4 extras and 1 category.

- `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#EXTRA_DEVICE` - The remote Bluetooth Device
- `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD` - The vendor specific command
- `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` - The AT command type which can be one of `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#AT_CMD_TYPE_READ`, `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#AT_CMD_TYPE_TEST`, or `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#AT_CMD_TYPE_SET`, `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#AT_CMD_TYPE_BASIC`,`https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#AT_CMD_TYPE_ACTION`.
- `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS` - Command arguments.

The category is the Company ID of the vendor defining the vendor-specific command. `https://developer.android.com/reference/android/bluetooth/BluetoothAssignedNumbers`

For example, for Plantronics specific events Category will be `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY`.55

For example, an AT+XEVENT=foo,3 will get translated into

- EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD = +XEVENT
- EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE = AT_CMD_TYPE_SET
- EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS = foo, 3

.   
For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.   
For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.   
Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

<br />

Constant Value:

"android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT"


### AT_CMD_TYPE_ACTION

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int AT_CMD_TYPE_ACTION
```

AT command type ACTION used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` For
example, AT+CHUP. There are no arguments for action commands.

<br />

Constant Value:

4
(0x00000004)


### AT_CMD_TYPE_BASIC

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int AT_CMD_TYPE_BASIC
```

AT command type BASIC used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` For
example, ATD. Single character commands and everything following the character are arguments.

<br />

Constant Value:

3
(0x00000003)


### AT_CMD_TYPE_READ

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int AT_CMD_TYPE_READ
```

AT command type READ used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` For
example, AT+VGM?. There are no arguments for this command type.

<br />

Constant Value:

0
(0x00000000)


### AT_CMD_TYPE_SET

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int AT_CMD_TYPE_SET
```

AT command type SET used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` For
example, AT+VGM=.

<br />

Constant Value:

2
(0x00000002)


### AT_CMD_TYPE_TEST

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int AT_CMD_TYPE_TEST
```

AT command type TEST used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE` For
example, AT+VGM=?. There are no arguments for this command type.

<br />

Constant Value:

1
(0x00000001)


### CODEC_TYPE_CVSD

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int CODEC_TYPE_CVSD
```

HFP codec type CVSD.

Continuous Variable Slope Delta modulation (CVSD) as defined by the Bluetooth SIG in the
HFP Specification.

<br />

Constant Value:

1
(0x00000001)


### CODEC_TYPE_LC3_SWB

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int CODEC_TYPE_LC3_SWB
```

HFP codec type LC3 SWB.

Low Complexity Communication Codec (LC3) for Super Wideband (SWB) as defined by the
Bluetooth SIG in the HFP Specification.

<br />

Constant Value:

3
(0x00000003)


### CODEC_TYPE_MSBC

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int CODEC_TYPE_MSBC
```

HFP codec type mSBC.

Modified Sub-Band Codec (mSBC) as defined by the Bluetooth SIG in the HFP Specification.

<br />

Constant Value:

2
(0x00000002)


### CODEC_TYPE_UNSUPPORTED

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int CODEC_TYPE_UNSUPPORTED
```

HFP codec type is not supported or cannot be determined

<br />

Constant Value:

-1
(0xffffffff)


### CODEC_TYPE_VENDOR_SPECIFIC

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int CODEC_TYPE_VENDOR_SPECIFIC
```

HFP vendor specific codec Type

<br />

Constant Value:

0
(0x00000000)


### EXTRA_DISCONNECTED_REASON

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_DISCONNECTED_REASON
```

Used as an int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_CONNECTION_STATE_CHANGED` intents for connection
failure reasons.

The value is one of the following:

- `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#SUCCESS`
- `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_UNKNOWN`
- `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_INSUFFICIENT_RESOURCES`
- `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_SDP_DISCOVERY_FAILED`
- `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_RFCOMM_CONNECTION_FAILED`

<br />

<br />

Constant Value:

"android.bluetooth.headset.extra.DISCONNECTED_REASON"


### EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS
```

A Parcelable String array extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_VENDOR_SPECIFIC_HEADSET_EVENT`
intents that contains the arguments to the vendor-specific command.

<br />

Constant Value:

"android.bluetooth.headset.extra.VENDOR_SPECIFIC_HEADSET_EVENT_ARGS"


### EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD
```

A String extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_VENDOR_SPECIFIC_HEADSET_EVENT` intents that contains
the name of the vendor-specific command.

<br />

Constant Value:

"android.bluetooth.headset.extra.VENDOR_SPECIFIC_HEADSET_EVENT_CMD"


### EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
```

An int extra field in `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_VENDOR_SPECIFIC_HEADSET_EVENT` intents that contains the
AT command type of the vendor-specific command.

<br />

Constant Value:

"android.bluetooth.headset.extra.VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE"


### STATE_AUDIO_CONNECTED

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATE_AUDIO_CONNECTED
```

Headset state when SCO audio is connected. This state can be one of `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE` or
`https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_PREVIOUS_STATE` of `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_AUDIO_STATE_CHANGED` intent.

<br />

Constant Value:

12
(0x0000000c)


### STATE_AUDIO_CONNECTING

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATE_AUDIO_CONNECTING
```

Headset state when SCO audio is connecting. This state can be one of `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE` or
`https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_PREVIOUS_STATE` of `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_AUDIO_STATE_CHANGED` intent.

<br />

Constant Value:

11
(0x0000000b)


### STATE_AUDIO_DISCONNECTED

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATE_AUDIO_DISCONNECTED
```

Headset state when SCO audio is not connected. This state can be one of `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE`
or `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_PREVIOUS_STATE` of `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_AUDIO_STATE_CHANGED` intent.

<br />

Constant Value:

10
(0x0000000a)


### VENDOR_RESULT_CODE_COMMAND_ANDROID

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String VENDOR_RESULT_CODE_COMMAND_ANDROID
```

A vendor-specific command for unsolicited result code.

<br />

Constant Value:

"+ANDROID"


### VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY
```

The intent category to be used with `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_VENDOR_SPECIFIC_HEADSET_EVENT` for the
companyId

<br />

Constant Value:

"android.bluetooth.headset.intent.category.companyid"


## Public methods

### getCodecType

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public int getCodecType (BluetoothDevice device)
```

Get the codec type of the given HFP connected device.

This method returns the codec type that has been negotiated between the AG and HF which is
available once the HFP SLC is established and the codec negotiation process is completed. The
negotiated codec can be retrieved regardless of whether a SCO audio connection is currently
active or not.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote Bluetooth device. Must not be null. <br /> |

| Returns ||
|---|---|
| `int` | The codec type of the given HFP connected device. Returns `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#CODEC_TYPE_UNSUPPORTED` if Bluetooth is off, the profile is not connected, the device is not connected, the codec negotiation is not completed, or an error occurs. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#CODEC_TYPE_LC3_SWB` - `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#CODEC_TYPE_MSBC` - `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#CODEC_TYPE_CVSD` - `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#CODEC_TYPE_VENDOR_SPECIFIC` - `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#CODEC_TYPE_UNSUPPORTED` |

### getConnectedDevices

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<BluetoothDevice> getConnectedDevices ()
```

Get connected devices for this specific profile.

Return the set of devices which are in state `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED`


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/bluetooth/BluetoothDevice>` | List of devices. The list will be empty on error. <br /> |

### getConnectionState

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getConnectionState (BluetoothDevice device)
```

Get the current connection state of the profile


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: Remote bluetooth device. <br /> |

| Returns ||
|---|---|
| `int` | State of the profile connection. One of `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED`, `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTING`, `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED`, `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTING` Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTING` - `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTING` |

### getDevicesMatchingConnectionStates

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<BluetoothDevice> getDevicesMatchingConnectionStates (int[] states)
```

Get a list of devices that match any of the given connection states.

If none of the devices match any of the given states, an empty list will be returned.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `states` | `int`: Array of states. States can be one of `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED`, `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTING`, `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED`, `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTING`, <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/bluetooth/BluetoothDevice>` | List of devices. The list will be empty on error. <br /> |

### isAudioConnected

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isAudioConnected (BluetoothDevice device)
```

Check if Bluetooth SCO audio is connected.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: Bluetooth headset <br /> |

| Returns ||
|---|---|
| `boolean` | true if SCO is connected, false otherwise or on error <br /> |

### isNoiseReductionSupported

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isNoiseReductionSupported (BluetoothDevice device)
```

Checks whether the headset supports some form of noise reduction.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: Bluetooth device. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if echo cancellation and/or noise reduction is supported, false otherwise <br /> |

### isVoiceRecognitionSupported

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isVoiceRecognitionSupported (BluetoothDevice device)
```

Checks whether the headset supports voice recognition.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: Bluetooth device. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if voice recognition is supported, false otherwise <br /> |

### sendVendorSpecificResultCode

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean sendVendorSpecificResultCode (BluetoothDevice device, 
                String command, 
                String arg)
```

Sends a vendor-specific unsolicited result code to the headset.

The actual string to be sent is `command + ": " + arg`. For example, if `command` is `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#VENDOR_RESULT_CODE_COMMAND_ANDROID` and `arg` is `"0"`, the
string `"+ANDROID: 0"` will be sent.

Currently only `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#VENDOR_RESULT_CODE_COMMAND_ANDROID` is allowed as `command`.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: Bluetooth headset. <br /> |
| `command` | `String`: A vendor-specific command. <br /> |
| `arg` | `String`: The argument that will be attached to the command. <br /> |

| Returns ||
|---|---|
| `boolean` | `false` if there is no headset connected, or if the command is not an allowed vendor-specific unsolicited result code, or on error. `true` otherwise. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `command` is `null`. |

### startVoiceRecognition

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean startVoiceRecognition (BluetoothDevice device)
```

Start Bluetooth voice recognition. This methods sends the voice recognition AT command to the
headset and establishes the audio connection.

Users can listen to `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_AUDIO_STATE_CHANGED`. If this function returns true,
this intent will be broadcasted with `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE` set to `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#STATE_AUDIO_CONNECTING`.

`https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE` will transition from `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#STATE_AUDIO_CONNECTING` to `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#STATE_AUDIO_CONNECTED` when audio connection is established and to `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#STATE_AUDIO_DISCONNECTED` in case of failure to establish the audio connection.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: Bluetooth headset <br /> |

| Returns ||
|---|---|
| `boolean` | false if there is no headset connected, or the connected headset doesn't support voice recognition, or voice recognition is already started, or audio channel is occupied, or on error, true otherwise <br /> |

### stopVoiceRecognition

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean stopVoiceRecognition (BluetoothDevice device)
```

Stop Bluetooth Voice Recognition mode, and shut down the Bluetooth audio path.

Users can listen to `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#ACTION_AUDIO_STATE_CHANGED`. If this function returns true,
this intent will be broadcasted with `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE` set to `https://developer.android.com/reference/android/bluetooth/BluetoothHeadset#STATE_AUDIO_DISCONNECTED`.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT`

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: Bluetooth headset <br /> |

| Returns ||
|---|---|
| `boolean` | false if there is no headset connected, or voice recognition has not started, or voice recognition has ended on this headset, or on error, true otherwise <br /> |

## Protected methods

### finalize

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void finalize ()
```

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
A subclass overrides the `finalize` method to dispose of
system resources or to perform other cleanup.


The general contract of `finalize` is that it is invoked
if and when the Java virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The `finalize` method may take any action, including
making this object available again to other threads; the usual purpose
of `finalize`, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.


The `finalize` method of class `Object` performs no
special action; it simply returns normally. Subclasses of
`Object` may override this definition.


The Java programming language does not guarantee which thread will
invoke the `finalize` method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.


After the `finalize` method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.


The `finalize` method is never invoked more than once by a Java
virtual machine for any given object.


Any exception thrown by the `finalize` method causes
the finalization of this object to be halted, but is otherwise
ignored.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/Throwable` |   |