# TransportHandle.ReceiveCallback

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

# ReceiveCallback

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/ranging/oob/TransportHandle.ReceiveCallback "View this page in Java")  

```
interface ReceiveCallback
```

|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [android.ranging.oob.TransportHandle.ReceiveCallback](https://developer.android.com/reference/kotlin/android/ranging/oob/TransportHandle.ReceiveCallback#) |

TransportHandle callback.

## Summary

|                                                                                                                                                                                              Public methods                                                                                                                                                                                              ||
|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onClose](https://developer.android.com/reference/kotlin/android/ranging/oob/TransportHandle.ReceiveCallback#onClose())`()` Notifies the receiver that the TransportHandle instance can't be used anymore to receive or send data.                                                                                 |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onDisconnect](https://developer.android.com/reference/kotlin/android/ranging/oob/TransportHandle.ReceiveCallback#onDisconnect())`()` Notifies the receiver that the TransportHandle instance can't be used to receive or send data until {@see onReconnect()} is called.                                          |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onReceiveData](https://developer.android.com/reference/kotlin/android/ranging/oob/TransportHandle.ReceiveCallback#onReceiveData(kotlin.ByteArray))`(`data:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)`)` Notifies and provides data received from the peer device. |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onReconnect](https://developer.android.com/reference/kotlin/android/ranging/oob/TransportHandle.ReceiveCallback#onReconnect())`()` Notifies the receiver the TransportHandle instance can be used again to send and receive data.                                                                                 |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSendFailed](https://developer.android.com/reference/kotlin/android/ranging/oob/TransportHandle.ReceiveCallback#onSendFailed())`()` Called when a data send operation fails.                                                                                                                                     |

## Public methods

### onClose

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

```
abstract fun onClose(): Unit
```

Notifies the receiver that the TransportHandle instance can't be used anymore to receive or send data. Also call this in[AutoCloseable.close()](https://developer.android.com/reference/kotlin/java/lang/AutoCloseable.html#close()).  

### onDisconnect

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

```
abstract fun onDisconnect(): Unit
```

Notifies the receiver that the TransportHandle instance can't be used to receive or send data until {@see onReconnect()} is called.  

### onReceiveData

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

```
abstract fun onReceiveData(data: ByteArray): Unit
```

Notifies and provides data received from the peer device.

|                                                                        Parameters                                                                         ||
|--------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `data` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html):the data received from the peer device. Must not be null. |

### onReconnect

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

```
abstract fun onReconnect(): Unit
```

Notifies the receiver the TransportHandle instance can be used again to send and receive data. Should only be called if {@see onDisconnect()} preceded it.  

### onSendFailed

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

```
abstract fun onSendFailed(): Unit
```

Called when a data send operation fails.