# BluetoothHidDevice.Callback

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice.Callback#pubctors)\|[Methods](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice.Callback#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice.Callback#inhmethods)  

# BluetoothHidDevice.Callback

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothHidDevice.Callback "View this page in Kotlin")\|Java

`
public
static

abstract
class
BluetoothHidDevice.Callback
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-----------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.bluetooth.BluetoothHidDevice.Callback |

<br />

*** ** * ** ***

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](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice.Callback#Callback())`() ` |

|                                                                                                                                                                                          ### Public methods                                                                                                                                                                                          ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[onAppStatusChanged](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice.Callback#onAppStatusChanged(android.bluetooth.BluetoothDevice,%20boolean))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` pluggedDevice, boolean registered) ` Callback called when application registration state changes.           |
| ` void` | ` `[onConnectionStateChanged](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice.Callback#onConnectionStateChanged(android.bluetooth.BluetoothDevice,%20int))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device, int state) ` Callback called when connection state with remote host was changed.            |
| ` void` | ` `[onGetReport](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice.Callback#onGetReport(android.bluetooth.BluetoothDevice,%20byte,%20byte,%20int))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device, byte type, byte id, int bufferSize) ` Callback called when GET_REPORT is received from remote host.   |
| ` void` | ` `[onInterruptData](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice.Callback#onInterruptData(android.bluetooth.BluetoothDevice,%20byte,%20byte[]))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device, byte reportId, byte[] data) ` Callback called when report data is received over interrupt channel. |
| ` void` | ` `[onSetProtocol](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice.Callback#onSetProtocol(android.bluetooth.BluetoothDevice,%20byte))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device, byte protocol) ` Callback called when SET_PROTOCOL is received from remote host.                                 |
| ` void` | ` `[onSetReport](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice.Callback#onSetReport(android.bluetooth.BluetoothDevice,%20byte,%20byte,%20byte[]))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device, byte type, byte id, byte[] data) ` Callback called when SET_REPORT is received from remote host.   |
| ` void` | ` `[onVirtualCableUnplug](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice.Callback#onVirtualCableUnplug(android.bluetooth.BluetoothDevice))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device) ` Callback called when Virtual Cable is removed.                                                           |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### Callback

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Callback ()
```

<br />

<br />

## Public methods

### onAppStatusChanged

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void onAppStatusChanged (BluetoothDevice pluggedDevice, 
                boolean registered)
```

Callback called when application registration state changes. Usually it's called due to either[Executor, Callback)](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice#registerApp(android.bluetooth.BluetoothHidDeviceAppSdpSettings,%20android.bluetooth.BluetoothHidDeviceAppQosSettings,%20android.bluetooth.BluetoothHidDeviceAppQosSettings,%20java.util.concurrent.Executor,%20android.bluetooth.BluetoothHidDevice.Callback))or[BluetoothHidDevice.unregisterApp()](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice#unregisterApp()), but can be also unsolicited in case e.g. Bluetooth was turned off in which case application is unregistered automatically.

<br />

|                                                                                                                                      Parameters                                                                                                                                       ||
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `pluggedDevice` | `BluetoothDevice`:[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)object which represents host that currently has Virtual Cable established with device. Only valid when application is registered, can be`null`. <br /> |
| `registered`    | `boolean`:`true`if application is registered,`false`otherwise. <br />                                                                                                                                                                                                |

### onConnectionStateChanged

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED)`state`.

<br />

|                                                                                             Parameters                                                                                             ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `device` | `BluetoothDevice`:[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)object representing host device which connection state was changed. <br /> |
| `state`  | `int`: Connection state as defined in[BluetoothProfile](https://developer.android.com/reference/android/bluetooth/BluetoothProfile). <br />                                              |

### onGetReport

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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[])](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice#replyReport(android.bluetooth.BluetoothDevice,%20byte,%20byte,%20byte[])).

<br />

|                                                    Parameters                                                     ||
|--------------|-----------------------------------------------------------------------------------------------------|
| `device`     | `BluetoothDevice` <br />                                                                            |
| `type`       | `byte`: Requested Report Type. <br />                                                               |
| `id`         | `byte`: Requested Report Id, can be 0 if no Report Id are defined in descriptor. <br />             |
| `bufferSize` | `int`: Requested buffer size, application shall respond with at least given number of bytes. <br /> |

### onInterruptData

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice#REPORT_TYPE_OUTPUT).

<br />

|               Parameters                ||
|------------|-----------------------------|
| `device`   | `BluetoothDevice` <br />    |
| `reportId` | `byte`: Report Id. <br />   |
| `data`     | `byte`: Report data. <br /> |

### onSetProtocol

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice#PROTOCOL_REPORT_MODE)shall be assumed.

<br />

|                Parameters                 ||
|------------|-------------------------------|
| `device`   | `BluetoothDevice` <br />      |
| `protocol` | `byte`: Protocol Mode. <br /> |

### onSetReport

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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)](https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice#reportError(android.bluetooth.BluetoothDevice,%20byte)).

<br />

|              Parameters               ||
|----------|-----------------------------|
| `device` | `BluetoothDevice` <br />    |
| `type`   | `byte`: Report Type. <br /> |
| `id`     | `byte`: Report Id. <br />   |
| `data`   | `byte`: Report data. <br /> |

### onVirtualCableUnplug

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void onVirtualCableUnplug (BluetoothDevice device)
```

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

<br />

|             Parameters             ||
|----------|--------------------------|
| `device` | `BluetoothDevice` <br /> |