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

# TrustPairingCallback

*** ** * ** ***

```
abstract class TrustPairingCallback
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.companion.CompanionDeviceManager.TrustPairingCallback](https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager.TrustPairingCallback#) |

Callback for applications to receive updates about and the outcome of `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#requestDeviceTrustPairing(kotlin.Int,%20android.companion.OutOfBandPairingRequest,%20kotlin.IntArray,%20java.util.concurrent.Executor,%20android.companion.CompanionDeviceManager.TrustPairingCallback)`

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager.TrustPairingCallback#TrustPairingCallback()()` <br /> |

| Public methods ||
|---|---|
| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager.TrustPairingCallback#onDeviceTrusted(android.companion.AssociationInfo)(associationInfo: https://developer.android.com/reference/kotlin/android/companion/AssociationInfo)` Invoked when the device is trusted. |
| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager.TrustPairingCallback#onFailure(kotlin.Int)(errorCode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Invoked if the trust pairing could not be created or explicitly failed. |
| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager.TrustPairingCallback#onTrustPairingCanceledFromRemote(android.companion.AssociationInfo,%20android.content.IntentSender)(associationInfo: https://developer.android.com/reference/kotlin/android/companion/AssociationInfo, cancelIntentSender: https://developer.android.com/reference/kotlin/android/content/IntentSender.html#)` Invoked when the trust pairing is canceled by the remote device. |
| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager.TrustPairingCallback#onTrustPairingPending(android.content.IntentSender)(intentSender: https://developer.android.com/reference/kotlin/android/content/IntentSender.html#)` Invoked when a trust pairing confirmation is required. |

## Public constructors

### TrustPairingCallback

```
TrustPairingCallback()
```

## Public methods

### onDeviceTrusted

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

```
abstract fun onDeviceTrusted(associationInfo: AssociationInfo): Unit
```

Invoked when the device is trusted.

| Parameters ||
|---|---|
| `associationInfo` | [AssociationInfo](https://developer.android.com/reference/kotlin/android/companion/AssociationInfo): contains details of the newly-trusted association. This value cannot be `null`. |

### onFailure

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

```
abstract fun onFailure(errorCode: Int): Unit
```

Invoked if the trust pairing could not be created or explicitly failed.

| Parameters ||
|---|---|
| `errorCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): One of: - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_UNKNOWN:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_PAIRING_TRANSPORT_NOT_ATTACHED:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_PAIRING_CANCELED:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_PAIRING_FAILED_TO_CREATE_PAIRING_DIALOG:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_PAIRING_PIN_CODE_NOT_MATCHING:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_PAIRING_ASSOCIATION_DOES_NOT_EXIST:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_OUT_OF_BAND_PAIRING_FAILED:kotlin.Int` . Value is one of the following: - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_UNKNOWN:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_PAIRING_TRANSPORT_NOT_ATTACHED:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_PAIRING_CANCELED:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_PAIRING_FAILED_TO_CREATE_PAIRING_DIALOG:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_PAIRING_PIN_CODE_NOT_MATCHING:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_PAIRING_ASSOCIATION_DOES_NOT_EXIST:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_RESUMPTION_FAILED:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/companion/CompanionDeviceManager#ERROR_TRUST_OUT_OF_BAND_PAIRING_FAILED:kotlin.Int` |

### onTrustPairingCanceledFromRemote

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

```
abstract fun onTrustPairingCanceledFromRemote(
    associationInfo: AssociationInfo, 
    cancelIntentSender: IntentSender
): Unit
```

Invoked when the trust pairing is canceled by the remote device. The application is expected to launch the provided `cancelIntentSender` to cancel the trust pairing.

| Parameters ||
|---|---|
| `associationInfo` | [AssociationInfo](https://developer.android.com/reference/kotlin/android/companion/AssociationInfo): contains details of the association. This value cannot be `null`. |
| `cancelIntentSender` | [IntentSender](https://developer.android.com/reference/kotlin/android/content/IntentSender.html#): an `https://developer.android.com/reference/kotlin/android/content/IntentSender.html#` which applications should launch in order to cancel the trust pairing dialog. This value cannot be `null`. |

### onTrustPairingPending

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

```
abstract fun onTrustPairingPending(intentSender: IntentSender): Unit
```

Invoked when a trust pairing confirmation is required. This can happen when the pairing was initiated by the local device. The application is expected to launch the provided `intentSender` to display the user confirmation dialog.

| Parameters ||
|---|---|
| `intentSender` | [IntentSender](https://developer.android.com/reference/kotlin/android/content/IntentSender.html#): an `https://developer.android.com/reference/kotlin/android/content/IntentSender.html#` which applications should use to launch the UI for the user to confirm the trust pairing. This value cannot be `null`. |