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

# UssdResponseCallback

*** ** * ** ***

```
abstract class UssdResponseCallback
```

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

Used to notify callers of `https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager#sendUssdRequest(kotlin.String,%20android.telephony.TelephonyManager.UssdResponseCallback,%20android.os.Handler)` when the network either successfully executes a USSD request, or if there was a failure while executing the request.

`https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager.UssdResponseCallback#onReceiveUssdResponse(android.telephony.TelephonyManager,%20kotlin.String,%20kotlin.CharSequence)` will be called if the USSD request has succeeded. `https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager.UssdResponseCallback#onReceiveUssdResponseFailed(android.telephony.TelephonyManager,%20kotlin.String,%20kotlin.Int)` will be called if the USSD request has failed.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager.UssdResponseCallback#UssdResponseCallback()()` <br /> |

| Public methods ||
|---|---|
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager.UssdResponseCallback#onReceiveUssdResponse(android.telephony.TelephonyManager,%20kotlin.String,%20kotlin.CharSequence)(telephonyManager: https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager!, request: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!, response: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html!)` Called when a USSD request has succeeded. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager.UssdResponseCallback#onReceiveUssdResponseFailed(android.telephony.TelephonyManager,%20kotlin.String,%20kotlin.Int)(telephonyManager: https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager!, request: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!, failureCode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Called when a USSD request has failed to complete. |

## Public constructors

### UssdResponseCallback

```
UssdResponseCallback()
```

## Public methods

### onReceiveUssdResponse

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

```
open fun onReceiveUssdResponse(
    telephonyManager: TelephonyManager!, 
    request: String!, 
    response: CharSequence!
): Unit
```

Called when a USSD request has succeeded. The `response` contains the USSD response received from the network. The calling app can choose to either display the response to the user or perform some operation based on the response.

USSD responses are unstructured text and their content is determined by the mobile network operator.

| Parameters ||
|---|---|
| `telephonyManager` | [TelephonyManager](https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager)!: the TelephonyManager the callback is registered to. |
| `request` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the USSD request sent to the mobile network. |
| `response` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!: the response to the USSD request provided by the mobile network. |

### onReceiveUssdResponseFailed

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

```
open fun onReceiveUssdResponseFailed(
    telephonyManager: TelephonyManager!, 
    request: String!, 
    failureCode: Int
): Unit
```

Called when a USSD request has failed to complete.

| Parameters ||
|---|---|
| `telephonyManager` | [TelephonyManager](https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager)!: the TelephonyManager the callback is registered to. |
| `request` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the USSD request sent to the mobile network. |
| `failureCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): failure code indicating why the request failed. Will be one of `https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager#USSD_RETURN_FAILURE:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager#USSD_ERROR_SERVICE_UNAVAIL:kotlin.Int`, or `https://developer.android.com/reference/kotlin/android/telephony/TelephonyManager#USSD_ERROR_NOT_ALLOWED:kotlin.Int`. |