to top
Android APIs
public abstract class

BluetoothGattServerCallback

extends Object
java.lang.Object
   ↳ android.bluetooth.BluetoothGattServerCallback

Class Overview

This abstract class is used to implement BluetoothGattServer callbacks.

Summary

Public Constructors
BluetoothGattServerCallback()
Public Methods
void onCharacteristicReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattCharacteristic characteristic)
A remote client has requested to read a local characteristic.
void onCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value)
A remote client has requested to write to a local characteristic.
void onConnectionStateChange(BluetoothDevice device, int status, int newState)
Callback indicating when a remote device has been connected or disconnected.
void onDescriptorReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor)
A remote client has requested to read a local descriptor.
void onDescriptorWriteRequest(BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value)
A remote client has requested to write to a local descriptor.
void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute)
Execute all pending write operations for this device.
void onServiceAdded(int status, BluetoothGattService service)
Indicates whether a local service has been added successfully.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public BluetoothGattServerCallback ()

Added in API level 18

Public Methods

public void onCharacteristicReadRequest (BluetoothDevice device, int requestId, int offset, BluetoothGattCharacteristic characteristic)

Added in API level 18

A remote client has requested to read a local characteristic.

An application must call sendResponse(BluetoothDevice, int, int, int, byte[]) to complete the request.

Parameters
device The remote device that has requested the read operation
requestId The Id of the request
offset Offset into the value of the characteristic
characteristic Characteristic to be read

public void onCharacteristicWriteRequest (BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value)

Added in API level 18

A remote client has requested to write to a local characteristic.

An application must call sendResponse(BluetoothDevice, int, int, int, byte[]) to complete the request.

Parameters
device The remote device that has requested the write operation
requestId The Id of the request
characteristic Characteristic to be written to.
preparedWrite true, if this write operation should be queued for later execution.
responseNeeded true, if the remote device requires a response
offset The offset given for the value
value The value the client wants to assign to the characteristic

public void onConnectionStateChange (BluetoothDevice device, int status, int newState)

Added in API level 18

Callback indicating when a remote device has been connected or disconnected.

Parameters
device Remote device that has been connected or disconnected.
status Status of the connect or disconnect operation.
newState Returns the new connection state. Can be one of STATE_DISCONNECTED or STATE_CONNECTED

public void onDescriptorReadRequest (BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor)

Added in API level 18

A remote client has requested to read a local descriptor.

An application must call sendResponse(BluetoothDevice, int, int, int, byte[]) to complete the request.

Parameters
device The remote device that has requested the read operation
requestId The Id of the request
offset Offset into the value of the characteristic
descriptor Descriptor to be read

public void onDescriptorWriteRequest (BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value)

Added in API level 18

A remote client has requested to write to a local descriptor.

An application must call sendResponse(BluetoothDevice, int, int, int, byte[]) to complete the request.

Parameters
device The remote device that has requested the write operation
requestId The Id of the request
descriptor Descriptor to be written to.
preparedWrite true, if this write operation should be queued for later execution.
responseNeeded true, if the remote device requires a response
offset The offset given for the value
value The value the client wants to assign to the descriptor

public void onExecuteWrite (BluetoothDevice device, int requestId, boolean execute)

Added in API level 18

Execute all pending write operations for this device.

An application must call sendResponse(BluetoothDevice, int, int, int, byte[]) to complete the request.

Parameters
device The remote device that has requested the write operations
requestId The Id of the request
execute Whether the pending writes should be executed (true) or cancelled (false)

public void onServiceAdded (int status, BluetoothGattService service)

Added in API level 18

Indicates whether a local service has been added successfully.

Parameters
status Returns GATT_SUCCESS if the service was added successfully.
service The service that has been added