java.lang.Object | |
↳ | android.bluetooth.BluetoothHeadset |
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 getProfileProxy(Context, BluetoothProfile.ServiceListener, int)
to get
the BluetoothHeadset proxy object. Use
closeProfileProxy(int, BluetoothProfile)
to close the service connection.
Android only supports one connected Bluetooth Headset at a time. Each method is protected with its appropriate permission.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ACTION_AUDIO_STATE_CHANGED | Intent used to broadcast the change in the Audio Connection state of the A2DP profile. | |||||||||
String | ACTION_CONNECTION_STATE_CHANGED | Intent used to broadcast the change in connection state of the Headset profile. | |||||||||
String | ACTION_VENDOR_SPECIFIC_HEADSET_EVENT | Intent used to broadcast that the headset has posted a vendor-specific event. | |||||||||
int | AT_CMD_TYPE_ACTION |
AT command type ACTION used with
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
For example, AT+CHUP.
|
|||||||||
int | AT_CMD_TYPE_BASIC |
AT command type BASIC used with
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
For example, ATD.
|
|||||||||
int | AT_CMD_TYPE_READ |
AT command type READ used with
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
For example, AT+VGM?.
|
|||||||||
int | AT_CMD_TYPE_SET |
AT command type SET used with
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
For example, AT+VGM= |
|||||||||
int | AT_CMD_TYPE_TEST |
AT command type TEST used with
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
For example, AT+VGM=?.
|
|||||||||
String | EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS |
A Parcelable String array extra field in
ACTION_VENDOR_SPECIFIC_HEADSET_EVENT intents that contains
the arguments to the vendor-specific command.
|
|||||||||
String | EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD |
A String extra field in ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
intents that contains the name of the vendor-specific command.
|
|||||||||
String | EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE |
An int extra field in ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
intents that contains the AT command type of the vendor-specific command.
|
|||||||||
int | STATE_AUDIO_CONNECTED | Headset state when SCO audio is connected. | |||||||||
int | STATE_AUDIO_CONNECTING | Headset state when SCO audio is connecting. | |||||||||
int | STATE_AUDIO_DISCONNECTED | Headset state when SCO audio is not connected. | |||||||||
String | VENDOR_RESULT_CODE_COMMAND_ANDROID | A vendor-specific command for unsolicited result code. | |||||||||
String | VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY |
The intent category to be used with ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
for the companyId
|
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.bluetooth.BluetoothProfile
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Get connected devices for this specific profile.
| |||||||||||
Get the current connection state of the profile
Requires | |||||||||||
Get a list of devices that match any of the given connection
states.
| |||||||||||
Check if Bluetooth SCO audio is connected.
| |||||||||||
Sends a vendor-specific unsolicited result code to the headset.
| |||||||||||
Start Bluetooth voice recognition.
| |||||||||||
Stop Bluetooth Voice Recognition mode, and shut down the
Bluetooth audio path.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
android.bluetooth.BluetoothProfile
|
Intent used to broadcast the change in the Audio Connection state of the A2DP profile.
This intent will have 3 extras:
EXTRA_STATE
- The current state of the profile. EXTRA_PREVIOUS_STATE
- The previous state of the profile. EXTRA_DEVICE
- The remote device. EXTRA_STATE
or EXTRA_PREVIOUS_STATE
can be any of
STATE_AUDIO_CONNECTED
, STATE_AUDIO_DISCONNECTED
,
Requires BLUETOOTH
permission
to receive.
Intent used to broadcast the change in connection state of the Headset profile.
This intent will have 3 extras:
EXTRA_STATE
- The current state of the profile. EXTRA_PREVIOUS_STATE
- The previous state of the profile. EXTRA_DEVICE
- The remote device. EXTRA_STATE
or EXTRA_PREVIOUS_STATE
can be any of
STATE_DISCONNECTED
, STATE_CONNECTING
,
STATE_CONNECTED
, STATE_DISCONNECTING
.
Requires BLUETOOTH
permission to
receive.
Intent used to broadcast that the headset has posted a vendor-specific event.
This intent will have 4 extras and 1 category.
EXTRA_DEVICE
- The remote Bluetooth Device
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD
- The vendor
specific command EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
- The AT
command type which can be one of AT_CMD_TYPE_READ
,
AT_CMD_TYPE_TEST
, or AT_CMD_TYPE_SET
,
AT_CMD_TYPE_BASIC
,AT_CMD_TYPE_ACTION
. EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS
- Command
arguments. The category is the Company ID of the vendor defining the
vendor-specific command. BluetoothAssignedNumbers
For example, for Plantronics specific events
Category will be VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY
.55
For example, an AT+XEVENT=foo,3 will get translated into
Requires BLUETOOTH
permission
to receive.
AT command type ACTION used with
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
For example, AT+CHUP. There are no arguments for action commands.
AT command type BASIC used with
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
For example, ATD. Single character commands and everything following the
character are arguments.
AT command type READ used with
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
For example, AT+VGM?. There are no arguments for this command type.
AT command type SET used with
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
For example, AT+VGM=
AT command type TEST used with
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE
For example, AT+VGM=?. There are no arguments for this command type.
A Parcelable String array extra field in
ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
intents that contains
the arguments to the vendor-specific command.
A String extra field in ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
intents that contains the name of the vendor-specific command.
An int extra field in ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
intents that contains the AT command type of the vendor-specific command.
Headset state when SCO audio is connected.
This state can be one of
EXTRA_STATE
or EXTRA_PREVIOUS_STATE
of
ACTION_AUDIO_STATE_CHANGED
intent.
Headset state when SCO audio is connecting.
This state can be one of
EXTRA_STATE
or EXTRA_PREVIOUS_STATE
of
ACTION_AUDIO_STATE_CHANGED
intent.
Headset state when SCO audio is not connected.
This state can be one of
EXTRA_STATE
or EXTRA_PREVIOUS_STATE
of
ACTION_AUDIO_STATE_CHANGED
intent.
A vendor-specific command for unsolicited result code.
The intent category to be used with ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
for the companyId
Get connected devices for this specific profile.
Return the set of devices which are in state STATE_CONNECTED
Requires BLUETOOTH
permission.
Get the current connection state of the profile
Requires BLUETOOTH
permission.
device | Remote bluetooth device. |
---|
STATE_CONNECTED
, STATE_CONNECTING
,
STATE_DISCONNECTED
, STATE_DISCONNECTING
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.
Requires BLUETOOTH
permission.
states | Array of states. States can be one of
STATE_CONNECTED , STATE_CONNECTING ,
STATE_DISCONNECTED , STATE_DISCONNECTING , |
---|
Check if Bluetooth SCO audio is connected.
Requires BLUETOOTH
permission.
device | Bluetooth headset |
---|
Sends a vendor-specific unsolicited result code to the headset.
The actual string to be sent is command + ": " + arg
.
For example, if command
is VENDOR_RESULT_CODE_COMMAND_ANDROID
and arg
is "0"
, the string "+ANDROID: 0"
will be sent.
Currently only VENDOR_RESULT_CODE_COMMAND_ANDROID
is allowed as command
.
Requires BLUETOOTH
permission.
device | Bluetooth headset. |
---|---|
command | A vendor-specific command. |
arg | The argument that will be attached to the command. |
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.IllegalArgumentException | if command is null .
|
---|
Start Bluetooth voice recognition. This methods sends the voice recognition AT command to the headset and establishes the audio connection.
Users can listen to ACTION_AUDIO_STATE_CHANGED
.
If this function returns true, this intent will be broadcasted with
EXTRA_STATE
set to STATE_AUDIO_CONNECTING
.
EXTRA_STATE
will transition from
STATE_AUDIO_CONNECTING
to STATE_AUDIO_CONNECTED
when
audio connection is established and to STATE_AUDIO_DISCONNECTED
in case of failure to establish the audio connection.
Requires BLUETOOTH
permission.
device | Bluetooth headset |
---|
Stop Bluetooth Voice Recognition mode, and shut down the Bluetooth audio path.
Requires BLUETOOTH
permission.
device | Bluetooth headset |
---|