BluetoothHealth | API reference | Android Developers (original) (raw)
Public API for Bluetooth Health Profile.
How to connect to a health device which is acting in the source role.
When done, close the health channel by calling [disconnectChannel(BluetoothDevice, BluetoothHealthAppConfiguration, int)](/reference/android/bluetooth/BluetoothHealth#disconnectChannel%28android.bluetooth.BluetoothDevice,%20android.bluetooth.BluetoothHealthAppConfiguration,%20int%29) and unregister the application configuration calling [unregisterAppConfiguration(BluetoothHealthAppConfiguration)](/reference/android/bluetooth/BluetoothHealth#unregisterAppConfiguration%28android.bluetooth.BluetoothHealthAppConfiguration%29)
Summary
| Constants | |
|---|---|
| int | APP_CONFIG_REGISTRATION_FAILURE This constant is deprecated. 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 | APP_CONFIG_REGISTRATION_SUCCESS This constant is deprecated. 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 | APP_CONFIG_UNREGISTRATION_FAILURE This constant is deprecated. 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 | APP_CONFIG_UNREGISTRATION_SUCCESS This constant is deprecated. 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 | CHANNEL_TYPE_RELIABLE This constant is deprecated. 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 | CHANNEL_TYPE_STREAMING This constant is deprecated. 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 | SINK_ROLE This constant is deprecated. 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 | SOURCE_ROLE This constant is deprecated. 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 | STATE_CHANNEL_CONNECTED This constant is deprecated. 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 | STATE_CHANNEL_CONNECTING This constant is deprecated. 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 | STATE_CHANNEL_DISCONNECTED This constant is deprecated. 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 | STATE_CHANNEL_DISCONNECTING This constant is deprecated. 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) |
| Inherited constants |
|---|
| From interfaceandroid.bluetooth.BluetoothProfile int A2DP Advanced Audio Distribution Profile (A2DP) int CSIP_SET_COORDINATOR Coordinated Set Identification Profile (CSIP) set coordinator String EXTRA_PREVIOUS_STATE Extra for the connection state intents of the individual profiles. String EXTRA_PROFILE Extra for the BluetoothProfile that the intent applies to. String EXTRA_STATE Extra for the connection state intents of the individual profiles. int GATT Generic Attribute Profile (GATT) int GATT_SERVER Generic Attribute Profile (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 Human Interface Device (HID) Device int LE_AUDIO LE Audio Device int SAP SIM Access Profile (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 | |
|---|---|
| boolean | connectChannelToSource(BluetoothDevice device, BluetoothHealthAppConfiguration config) This method is deprecated. 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) |
| boolean | disconnectChannel(BluetoothDevice device, BluetoothHealthAppConfiguration config, int channelId) This method is deprecated. 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) |
| List<BluetoothDevice> | getConnectedDevices() Get connected devices for the health profile. |
| int | getConnectionState(BluetoothDevice device) Get the current connection state of the profile. |
| List<BluetoothDevice> | getDevicesMatchingConnectionStates(int[] states) Get a list of devices that match any of the given connection states. |
| ParcelFileDescriptor | getMainChannelFd(BluetoothDevice device, BluetoothHealthAppConfiguration config) This method is deprecated. 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) |
| boolean | registerSinkAppConfiguration(String name, int dataType, BluetoothHealthCallback callback) This method is deprecated. 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) |
| boolean | unregisterAppConfiguration(BluetoothHealthAppConfiguration config) This method is deprecated. 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) |
| Inherited methods |
|---|
| From class java.lang.Object Object clone() Creates and returns a copy of this object. boolean equals(Object obj) Indicates whether some other object is "equal to" this one. void finalize() Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. finalClass<?> getClass() Returns the runtime class of this Object. int hashCode() Returns a hash code value for the object. final void notify() Wakes up a single thread that is waiting on this object's monitor. final void notifyAll() Wakes up all threads that are waiting on this object's monitor. String toString() Returns a string representation of the object. final void wait(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 wait(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 wait() Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
| From interface android.bluetooth.BluetoothProfile abstractList<BluetoothDevice> getConnectedDevices() Get connected devices for this specific profile. abstract int getConnectionState(BluetoothDevice device) Get the current connection state of the profile abstractList<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) Get a list of devices that match any of the given connection states. |
Constants
Public methods
connectChannelToSource
public boolean connectChannelToSource (BluetoothDevice device, BluetoothHealthAppConfiguration config)
This method is deprecated.
Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as [BluetoothGatt](/reference/android/bluetooth/BluetoothGatt), [BluetoothAdapter.listenUsingL2capChannel()](/reference/android/bluetooth/BluetoothAdapter#listenUsingL2capChannel%28%29), or [BluetoothDevice.createL2capChannel(int)](/reference/android/bluetooth/BluetoothDevice#createL2capChannel%28int%29)
Connect to a health device which has the [SOURCE_ROLE](/reference/android/bluetooth/BluetoothHealth#SOURCE%5FROLE). This is an asynchronous call. If this function returns true, the callback associated with the application configuration will be called.
For apps targeting [Build.VERSION_CODES.R](/reference/android/os/Build.VERSION%5FCODES#R) or lower, this requires the [Manifest.permission.BLUETOOTH](/reference/android/Manifest.permission#BLUETOOTH) permission which can be gained with a simple <uses-permission> manifest tag.
For apps targeting [Build.VERSION_CODES.S](/reference/android/os/Build.VERSION%5FCODES#S) or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](/reference/android/Manifest.permission#BLUETOOTH%5FCONNECT) permission which can be gained with [android.app.Activity.requestPermissions(String[],int)](/reference/android/app/Activity#requestPermissions%28java.lang.String[],%20int%29).
Requires [Manifest.permission.BLUETOOTH_CONNECT](/reference/android/Manifest.permission#BLUETOOTH%5FCONNECT)
| Parameters | |
|---|---|
| device | BluetoothDevice: The remote Bluetooth device. |
| config | BluetoothHealthAppConfiguration: The application configuration which has been registered using registerSinkAppConfiguration(String,int,BluetoothHealthCallback) |
| Returns | |
|---|---|
| boolean | If true, the callback associated with the application config will be called. |
disconnectChannel
public boolean disconnectChannel (BluetoothDevice device, BluetoothHealthAppConfiguration config, int channelId)
This method is deprecated.
Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as [BluetoothGatt](/reference/android/bluetooth/BluetoothGatt), [BluetoothAdapter.listenUsingL2capChannel()](/reference/android/bluetooth/BluetoothAdapter#listenUsingL2capChannel%28%29), or [BluetoothDevice.createL2capChannel(int)](/reference/android/bluetooth/BluetoothDevice#createL2capChannel%28int%29)
Disconnect a connected health channel. This is an asynchronous call. If this function returns true, the callback associated with the application configuration will be called.
For apps targeting [Build.VERSION_CODES.R](/reference/android/os/Build.VERSION%5FCODES#R) or lower, this requires the [Manifest.permission.BLUETOOTH](/reference/android/Manifest.permission#BLUETOOTH) permission which can be gained with a simple <uses-permission> manifest tag.
For apps targeting [Build.VERSION_CODES.S](/reference/android/os/Build.VERSION%5FCODES#S) or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](/reference/android/Manifest.permission#BLUETOOTH%5FCONNECT) permission which can be gained with [android.app.Activity.requestPermissions(String[],int)](/reference/android/app/Activity#requestPermissions%28java.lang.String[],%20int%29).
Requires [Manifest.permission.BLUETOOTH_CONNECT](/reference/android/Manifest.permission#BLUETOOTH%5FCONNECT)
| Parameters | |
|---|---|
| device | BluetoothDevice: The remote Bluetooth device. |
| config | BluetoothHealthAppConfiguration: The application configuration which has been registered using registerSinkAppConfiguration(String,int,BluetoothHealthCallback) |
| channelId | int: The channel id associated with the channel |
| Returns | |
|---|---|
| boolean | If true, the callback associated with the application config will be called. |