BluetoothHealth
classBluetoothHealth: BluetoothProfile
kotlin.Any | |
↳ | android.bluetooth.BluetoothHealth |
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
to register an application configuration connectChannelToSource
. Some devices will connect the channel automatically. The BluetoothHealth
callback will inform the application of channel state change. disconnectChannel
and unregister the application configuration calling unregisterAppConfiguration
Summary
Constants | |
---|---|
static Int |
Health App Configuration registration failure |
static Int |
Health App Configuration registration success |
static Int |
Health App Configuration un-registration failure |
static Int |
Health App Configuration un-registration success |
static Int |
Health Profile - Channel Type used - Reliable |
static Int |
Health Profile - Channel Type used - Streaming |
static Int |
Health Profile Sink Role the device talking to the health device. |
static Int |
Health Profile Source Role - the health device. |
static Int |
Health Channel Connection State - Connected |
static Int |
Health Channel Connection State - Connecting |
static Int |
Health Channel Connection State - Disconnected |
static Int |
Health Channel Connection State - Disconnecting |
Inherited constants | |
---|---|
Public methods | |
---|---|
Boolean |
connectChannelToSource(device: BluetoothDevice!, config: BluetoothHealthAppConfiguration!) Connect to a health device which has the |
Boolean |
disconnectChannel(device: BluetoothDevice!, config: BluetoothHealthAppConfiguration!, channelId: Int) Disconnect a connected health channel. |
MutableList<BluetoothDevice!>! |
Get connected devices for the health profile. |
Int |
getConnectionState(device: BluetoothDevice!) Get the current connection state of the profile. |
MutableList<BluetoothDevice!>! |
getDevicesMatchingConnectionStates(states: IntArray!) Get a list of devices that match any of the given connection states. |
ParcelFileDescriptor! |
getMainChannelFd(device: BluetoothDevice!, config: BluetoothHealthAppConfiguration!) Get the file descriptor of the main channel associated with the remote device and application configuration. |
Boolean |
registerSinkAppConfiguration(name: String!, dataType: Int, callback: BluetoothHealthCallback!) Register an application configuration that acts as a Health SINK. |
Boolean |
Unregister an application configuration that has been registered using |
Constants
APP_CONFIG_REGISTRATION_FAILURE
static valAPP_CONFIG_REGISTRATION_FAILURE: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health App Configuration registration failure
Value: 1
APP_CONFIG_REGISTRATION_SUCCESS
static valAPP_CONFIG_REGISTRATION_SUCCESS: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health App Configuration registration success
Value: 0
APP_CONFIG_UNREGISTRATION_FAILURE
static valAPP_CONFIG_UNREGISTRATION_FAILURE: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health App Configuration un-registration failure
Value: 3
APP_CONFIG_UNREGISTRATION_SUCCESS
static valAPP_CONFIG_UNREGISTRATION_SUCCESS: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health App Configuration un-registration success
Value: 2
CHANNEL_TYPE_RELIABLE
static valCHANNEL_TYPE_RELIABLE: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health Profile - Channel Type used - Reliable
Value: 10
CHANNEL_TYPE_STREAMING
static valCHANNEL_TYPE_STREAMING: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health Profile - Channel Type used - Streaming
Value: 11
SINK_ROLE
static valSINK_ROLE: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health Profile Sink Role the device talking to the health device.
Value: 2
SOURCE_ROLE
static valSOURCE_ROLE: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health Profile Source Role - the health device.
Value: 1
STATE_CHANNEL_CONNECTED
static valSTATE_CHANNEL_CONNECTED: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health Channel Connection State - Connected
Value: 2
STATE_CHANNEL_CONNECTING
static valSTATE_CHANNEL_CONNECTING: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health Channel Connection State - Connecting
Value: 1
STATE_CHANNEL_DISCONNECTED
static valSTATE_CHANNEL_DISCONNECTED: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health Channel Connection State - Disconnected
Value: 0
STATE_CHANNEL_DISCONNECTING
static valSTATE_CHANNEL_DISCONNECTING: Int
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Health Channel Connection State - Disconnecting
Value: 3
Public methods
connectChannelToSource
funconnectChannelToSource(
device: BluetoothDevice!,
config: BluetoothHealthAppConfiguration!
): Boolean
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.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 android.Manifest.permission#BLUETOOTH_CONNECT
Parameters | |
---|---|
device |
BluetoothDevice!: The remote Bluetooth device. |
config |
BluetoothHealthAppConfiguration!: The application configuration which has been registered using registerSinkAppConfiguration(java.lang.String,int,android.bluetooth.BluetoothHealthCallback) |
Return | |
---|---|
Boolean |
If true, the callback associated with the application config will be called. |
disconnectChannel
fundisconnectChannel(
device: BluetoothDevice!,
config: BluetoothHealthAppConfiguration!,
channelId: Int
): Boolean
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.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 android.Manifest.permission#BLUETOOTH_CONNECT
Parameters | |
---|---|
device |
BluetoothDevice!: The remote Bluetooth device. |
config |
BluetoothHealthAppConfiguration!: The application configuration which has been registered using registerSinkAppConfiguration(java.lang.String,int,android.bluetooth.BluetoothHealthCallback) |
channelId |
Int: The channel id associated with the channel |
Return | |
---|---|
Boolean |
If true, the callback associated with the application config will be called. |
getConnectedDevices
fungetConnectedDevices(): MutableList<BluetoothDevice!>!
Deprecated: Deprecated in Java.
Get connected devices for the health profile.
Return the set of devices which are in state STATE_CONNECTED
This is not specific to any application configuration but represents the connection state of the local Bluetooth adapter for this profile. This can be used by applications like status bar which would just like to know the state of the local adapter.
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 android.Manifest.permission#BLUETOOTH_CONNECT
Return | |
---|---|
MutableList<BluetoothDevice!>! |
List of devices. The list will be empty on error. |
getConnectionState
fungetConnectionState(device: BluetoothDevice!): Int
Deprecated: Deprecated in Java.
Get the current connection state of the profile.
This is not specific to any application configuration but represents the connection state of the local Bluetooth adapter with the remote device. This can be used by applications like status bar which would just like to know the state of the local adapter.
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 android.Manifest.permission#BLUETOOTH_CONNECT
Parameters | |
---|---|
device |
BluetoothDevice!: Remote bluetooth device. |
Return | |
---|---|
Int |
State of the profile connection. One of STATE_CONNECTED , STATE_CONNECTING , STATE_DISCONNECTED , STATE_DISCONNECTING |
getDevicesMatchingConnectionStates
fungetDevicesMatchingConnectionStates(states: IntArray!): MutableList<BluetoothDevice!>!
Deprecated: Deprecated in Java.
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.
This is not specific to any application configuration but represents the connection state of the local Bluetooth adapter for this profile. This can be used by applications like status bar which would just like to know the state of the local adapter.
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 android.Manifest.permission#BLUETOOTH_CONNECT
Parameters | |
---|---|
states |
IntArray!: Array of states. States can be one of STATE_CONNECTED , STATE_CONNECTING , STATE_DISCONNECTED , STATE_DISCONNECTING , |
Return | |
---|---|
MutableList<BluetoothDevice!>! |
List of devices. The list will be empty on error. |
getMainChannelFd
fungetMainChannelFd(
device: BluetoothDevice!,
config: BluetoothHealthAppConfiguration!
): ParcelFileDescriptor!
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Get the file descriptor of the main channel associated with the remote device and application configuration.
It's the responsibility of the caller to close the ParcelFileDescriptor when done.
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 android.Manifest.permission#BLUETOOTH_CONNECT
Parameters | |
---|---|
device |
BluetoothDevice!: The remote Bluetooth health device |
config |
BluetoothHealthAppConfiguration!: The application configuration |
Return | |
---|---|
ParcelFileDescriptor! |
null on failure, ParcelFileDescriptor on success. |
registerSinkAppConfiguration
funregisterSinkAppConfiguration(
name: String!,
dataType: Int,
callback: BluetoothHealthCallback!
): Boolean
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Register an application configuration that acts as a Health SINK. This is the configuration that will be used to communicate with health devices which will act as the SOURCE_ROLE
. This is an asynchronous call and so the callback is used to notify success or failure if the function returns true.
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 android.Manifest.permission#BLUETOOTH_CONNECT
Parameters | |
---|---|
name |
String!: The friendly name associated with the application or configuration. |
dataType |
Int: The dataType of the Source role of Health Profile to which the sink wants to connect to. |
callback |
BluetoothHealthCallback!: A callback to indicate success or failure of the registration and all operations done on this application configuration. |
Return | |
---|---|
Boolean |
If true, callback will be called. |
unregisterAppConfiguration
fununregisterAppConfiguration(config: BluetoothHealthAppConfiguration!): Boolean
Deprecated: Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as BluetoothGatt
, android.bluetooth.BluetoothAdapter#listenUsingL2capChannel()
, or android.bluetooth.BluetoothDevice#createL2capChannel(int)
Unregister an application configuration that has been registered using registerSinkAppConfiguration
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 android.Manifest.permission#BLUETOOTH_CONNECT
Parameters | |
---|---|
config |
BluetoothHealthAppConfiguration!: The health app configuration |
Return | |
---|---|
Boolean |
Success or failure. |