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

BluetoothHidDevice.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

BluetoothHidDevice.Callback

BluetoothHidDevice.Callback ()

Public methods

onAppStatusChanged

void onAppStatusChanged (BluetoothDevice pluggedDevice, 
                boolean registered)

Callback called when application registration state changes. Usually it's called due to either (String, String, String, byte, byte[], Executor, Callback) or 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

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 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

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 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

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

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

Parameters
device BluetoothDevice

reportId byte: Report Id.

data byte: Report data.

onSetProtocol

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, PROTOCOL_REPORT_MODE shall be assumed.

Parameters
device BluetoothDevice

protocol byte: Protocol Mode.

onSetReport

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 reportError(BluetoothDevice, byte).

Parameters
device BluetoothDevice

type byte: Report Type.

id byte: Report Id.

data byte: Report data.

onVirtualCableUnplug

void onVirtualCableUnplug (BluetoothDevice device)

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

Parameters
device BluetoothDevice