BluetoothHidDevice.Callback


public static abstract class BluetoothHidDevice.Callback
extends Object

java.lang.Object
   ↳ android.bluetooth.BluetoothHidDevice.Callback


The template class that applications use to call callback functions on events from the HID host. Callback functions are wrapped in this class and registered to the Android system during app registration.

Summary

Public constructors

Callback()

Public methods

void onAppStatusChanged(BluetoothDevice pluggedDevice, boolean registered)

Callback called when application registration state changes.

void onConnectionStateChanged(BluetoothDevice device, int state)

Callback called when connection state with remote host was changed.

void onGetReport(BluetoothDevice device, byte type, byte id, int bufferSize)

Callback called when GET_REPORT is received from remote host.

void onInterruptData(BluetoothDevice device, byte reportId, byte[] data)

Callback called when report data is received over interrupt channel.

void onSetProtocol(BluetoothDevice device, byte protocol)

Callback called when SET_PROTOCOL is received from remote host.

void onSetReport(BluetoothDevice device, byte type, byte id, byte[] data)

Callback called when SET_REPORT is received from remote host.

void onVirtualCableUnplug(BluetoothDevice device)

Callback called when Virtual Cable is removed.

Inherited methods

Public constructors

Callback

Added in API level 28
public Callback ()

Public methods

onAppStatusChanged

Added in API level 28
public void onAppStatusChanged (BluetoothDevice pluggedDevice, 
                boolean registered)

Callback called when application registration state changes. Usually it's called due to either Executor, Callback) or BluetoothHidDevice#unregisterApp() , but can be also unsolicited in case e.g. Bluetooth was turned off in which case application is unregistered automatically.

Parameters
pluggedDevice BluetoothDevice: BluetoothDevice object which represents host that currently has Virtual Cable established with device. Only valid when application is registered, can be null.

registered boolean: true if application is registered, false otherwise.

onConnectionStateChanged

Added in API level 28
public void onConnectionStateChanged (BluetoothDevice device, 
                int state)

Callback called when connection state with remote host was changed. Application can assume than Virtual Cable is established when called with BluetoothProfile.STATE_CONNECTED state.

Parameters
device BluetoothDevice: BluetoothDevice object representing host device which connection state was changed.

state int: Connection state as defined in BluetoothProfile.

onGetReport

Added in API level 28
public void onGetReport (BluetoothDevice device, 
                byte type, 
                byte id, 
                int bufferSize)

Callback called when GET_REPORT is received from remote host. Should be replied by application using BluetoothHidDevice#replyReport(BluetoothDevice, byte, byte, byte[]).

Parameters
device BluetoothDevice

type byte: Requested Report Type.

id byte: Requested Report Id, can be 0 if no Report Id are defined in descriptor.

bufferSize int: Requested buffer size, application shall respond with at least given number of bytes.

onInterruptData

Added in API level 28
public void onInterruptData (BluetoothDevice device, 
                byte reportId, 
                byte[] data)

Callback called when report data is received over interrupt channel. Report Type is assumed to be BluetoothHidDevice#REPORT_TYPE_OUTPUT.

Parameters
device BluetoothDevice

reportId byte: Report Id.

data byte: Report data.

onSetProtocol

Added in API level 28
public void onSetProtocol (BluetoothDevice device, 
                byte protocol)

Callback called when SET_PROTOCOL is received from remote host. Application shall use this information to send only reports valid for given protocol mode. By default, BluetoothHidDevice.PROTOCOL_REPORT_MODE shall be assumed.

Parameters
device BluetoothDevice

protocol byte: Protocol Mode.

onSetReport

Added in API level 28
public void onSetReport (BluetoothDevice device, 
                byte type, 
                byte id, 
                byte[] data)

Callback called when SET_REPORT is received from remote host. In case received data are invalid, application shall respond with BluetoothHidDevice.reportError(android.bluetooth.BluetoothDevice, byte).

Parameters
device BluetoothDevice

type byte: Report Type.

id byte: Report Id.

data byte: Report data.

onVirtualCableUnplug

Added in API level 28
public void onVirtualCableUnplug (BluetoothDevice device)

Callback called when Virtual Cable is removed. After this callback is received connection will be disconnected automatically.

Parameters
device BluetoothDevice