BluetoothProfile


public interface BluetoothProfile

android.bluetooth.BluetoothProfile


Public APIs for the Bluetooth Profiles.

Clients should call BluetoothAdapter#getProfileProxy, to get the Profile Proxy. Each public profile implements this interface.

Summary

Nested classes

interface BluetoothProfile.ServiceListener

An interface for notifying BluetoothProfile IPC clients when they have been connected or disconnected to the service. 

Constants

int A2DP

A2DP profile.

int CSIP_SET_COORDINATOR

Coordinated Set Identification Profile set coordinator

String EXTRA_PREVIOUS_STATE

Extra for the connection state intents of the individual profiles.

String EXTRA_STATE

Extra for the connection state intents of the individual profiles.

int GATT

GATT

int GATT_SERVER

GATT_SERVER

int HAP_CLIENT

int HEADSET

Headset and Handsfree profile

int 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 BluetoothGatt, BluetoothAdapter.listenUsingL2capChannel(), or BluetoothDevice.createL2capChannel(int)

int HEARING_AID

Hearing Aid Device

int HID_DEVICE

HID Device

int LE_AUDIO

LE Audio Device

int SAP

int STATE_CONNECTED

The profile is in connected state

int STATE_CONNECTING

The profile is in connecting state

int STATE_DISCONNECTED

The profile is in disconnected state

int STATE_DISCONNECTING

The profile is in disconnecting state

Public methods

abstract List<BluetoothDevice> getConnectedDevices()

Get connected devices for this specific profile.

abstract int getConnectionState(BluetoothDevice device)

Get the current connection state of the profile

abstract List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states)

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

Constants

A2DP

Added in API level 11
public static final int A2DP

A2DP profile.

Constant Value: 2 (0x00000002)

CSIP_SET_COORDINATOR

Added in API level 33
public static final int CSIP_SET_COORDINATOR

Coordinated Set Identification Profile set coordinator

Constant Value: 25 (0x00000019)

EXTRA_PREVIOUS_STATE

Added in API level 11
public static final String EXTRA_PREVIOUS_STATE

Extra for the connection state intents of the individual profiles.

This extra represents the previous connection state of the profile of the Bluetooth device.

Constant Value: "android.bluetooth.profile.extra.PREVIOUS_STATE"

EXTRA_STATE

Added in API level 11
public static final String EXTRA_STATE

Extra for the connection state intents of the individual profiles.

This extra represents the current connection state of the profile of the Bluetooth device.

Constant Value: "android.bluetooth.profile.extra.STATE"

GATT

Added in API level 18
public static final int GATT

GATT

Constant Value: 7 (0x00000007)

GATT_SERVER

Added in API level 18
public static final int GATT_SERVER

GATT_SERVER

Constant Value: 8 (0x00000008)

HAP_CLIENT

Added in API level 33
public static final int HAP_CLIENT

Constant Value: 28 (0x0000001c)

HEADSET

Added in API level 11
public static final int HEADSET

Headset and Handsfree profile

Constant Value: 1 (0x00000001)

HEALTH

Added in API level 14
Deprecated in API level 29
public static final int 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 BluetoothGatt, BluetoothAdapter.listenUsingL2capChannel(), or BluetoothDevice.createL2capChannel(int)

Health Profile

Constant Value: 3 (0x00000003)

HEARING_AID

Added in API level 29
public static final int HEARING_AID

Hearing Aid Device

Constant Value: 21 (0x00000015)

HID_DEVICE

Added in API level 28
public static final int HID_DEVICE

HID Device

Constant Value: 19 (0x00000013)

LE_AUDIO

Added in API level 33
public static final int LE_AUDIO

LE Audio Device

Constant Value: 22 (0x00000016)

SAP

Added in API level 23
public static final int SAP

Constant Value: 10 (0x0000000a)

STATE_CONNECTED

Added in API level 11
public static final int STATE_CONNECTED

The profile is in connected state

Constant Value: 2 (0x00000002)

STATE_CONNECTING

Added in API level 11
public static final int STATE_CONNECTING

The profile is in connecting state

Constant Value: 1 (0x00000001)

STATE_DISCONNECTED

Added in API level 11
public static final int STATE_DISCONNECTED

The profile is in disconnected state

Constant Value: 0 (0x00000000)

STATE_DISCONNECTING

Added in API level 11
public static final int STATE_DISCONNECTING

The profile is in disconnecting state

Constant Value: 3 (0x00000003)

Public methods

getConnectedDevices

Added in API level 11
public abstract List<BluetoothDevice> getConnectedDevices ()

Get connected devices for this specific profile.

Return the set of devices which are in state STATE_CONNECTED

Returns
List<BluetoothDevice> List of devices. The list will be empty on error.

getConnectionState

Added in API level 11
public abstract int getConnectionState (BluetoothDevice device)

Get the current connection state of the profile

Parameters
device BluetoothDevice: Remote bluetooth device.

Returns
int State of the profile connection. One of STATE_CONNECTED, STATE_CONNECTING, STATE_DISCONNECTED, STATE_DISCONNECTING Value is STATE_DISCONNECTED, STATE_CONNECTING, STATE_CONNECTED, or STATE_DISCONNECTING

getDevicesMatchingConnectionStates

Added in API level 11
public abstract 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.

Parameters
states int: Array of states. States can be one of STATE_CONNECTED, STATE_CONNECTING, STATE_DISCONNECTED, STATE_DISCONNECTING,

Returns
List<BluetoothDevice> List of devices. The list will be empty on error.