BluetoothHealth | API reference | Android Developers
public
final
class
BluetoothHealth
extends Object
implements
BluetoothProfile
This class 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)
Public API for Bluetooth Health Profile.
BluetoothHealth is a proxy object for controlling the Bluetooth Service via IPC.
How to connect to a health device which is acting in the source role.
BluetoothAdapter.getProfileProxy to get the BluetoothHealth proxy object.
BluetoothHealth callback and call registerSinkAppConfiguration(String, int, BluetoothHealthCallback) to
register an application configuration
connectChannelToSource(BluetoothDevice, BluetoothHealthAppConfiguration). Some devices will connect
the channel automatically. The BluetoothHealth callback will inform the application
of channel state change.
disconnectChannel(BluetoothDevice, BluetoothHealthAppConfiguration, int) and unregister the
application configuration calling unregisterAppConfiguration(BluetoothHealthAppConfiguration)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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Inherited constants | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
From interface
|
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 |
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 |
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 |
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 |
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 |
Inherited methods | |||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
From class
| |||||||||||||||||||||||
|
From interface
| |||||||||||||||||||||||
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, BluetoothAdapter.listenUsingL2capChannel(), or BluetoothDevice.createL2capChannel(int)
Connect to a health device which has the SOURCE_ROLE. 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 or lower, this requires the Manifest.permission.BLUETOOTH permission which can be gained with a simple <uses-permission> manifest tag.
For apps targeting Build.VERSION_CODES.S or or higher, this requires the
Manifest.permission.BLUETOOTH_CONNECT permission which can be gained with android.app.Activity.requestPermissions(String[],int).
Requires Manifest.permission.BLUETOOTH_CONNECT
| 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, BluetoothAdapter.listenUsingL2capChannel(), or BluetoothDevice.createL2capChannel(int)
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 or lower, this requires the Manifest.permission.BLUETOOTH permission which can be gained with a simple <uses-permission> manifest tag.
For apps targeting Build.VERSION_CODES.S or or higher, this requires the
Manifest.permission.BLUETOOTH_CONNECT permission which can be gained with android.app.Activity.requestPermissions(String[],int).
Requires Manifest.permission.BLUETOOTH_CONNECT
| 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. |