Stay organized with collections
Save and categorize content based on your preferences.
UssdResponseCallback
abstract class UssdResponseCallback
Used to notify callers of TelephonyManager.sendUssdRequest(String, UssdResponseCallback, Handler)
when the network either successfully executes a USSD request, or if there was a failure while executing the request.
onReceiveUssdResponse(android.telephony.TelephonyManager,java.lang.String,java.lang.CharSequence)
will be called if the USSD request has succeeded. onReceiveUssdResponseFailed(android.telephony.TelephonyManager,java.lang.String,int)
will be called if the USSD request has failed.
Summary
Public methods |
open Unit |
Called when a USSD request has succeeded.
|
open Unit |
Called when a USSD request has failed to complete.
|
Public constructors
UssdResponseCallback
UssdResponseCallback()
Public methods
onReceiveUssdResponse
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!: the TelephonyManager the callback is registered to. |
request |
String!: the USSD request sent to the mobile network. |
response |
CharSequence!: the response to the USSD request provided by the mobile network. |
onReceiveUssdResponseFailed
open fun onReceiveUssdResponseFailed(
telephonyManager: TelephonyManager!,
request: String!,
failureCode: Int
): Unit
Called when a USSD request has failed to complete.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# TelephonyManager.UssdResponseCallback\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nUssdResponseCallback\n====================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/telephony/TelephonyManager.UssdResponseCallback \"View this page in Java\") \n\n```\nabstract class UssdResponseCallback\n```\n\n|---|--------------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.telephony.TelephonyManager.UssdResponseCallback](#) |\n\nUsed to notify callers of [TelephonyManager.sendUssdRequest(String, UssdResponseCallback, Handler)](/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.\n\n[onReceiveUssdResponse(android.telephony.TelephonyManager,java.lang.String,java.lang.CharSequence)](#onReceiveUssdResponse(android.telephony.TelephonyManager,%20kotlin.String,%20kotlin.CharSequence)) will be called if the USSD request has succeeded. [onReceiveUssdResponseFailed(android.telephony.TelephonyManager,java.lang.String,int)](#onReceiveUssdResponseFailed(android.telephony.TelephonyManager,%20kotlin.String,%20kotlin.Int)) will be called if the USSD request has failed.\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------|---|\n| [UssdResponseCallback](#UssdResponseCallback())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onReceiveUssdResponse](#onReceiveUssdResponse(android.telephony.TelephonyManager,%20kotlin.String,%20kotlin.CharSequence))`(`telephonyManager:` `[TelephonyManager](/reference/kotlin/android/telephony/TelephonyManager)!`, `request:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `response:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`)` Called when a USSD request has succeeded. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onReceiveUssdResponseFailed](#onReceiveUssdResponseFailed(android.telephony.TelephonyManager,%20kotlin.String,%20kotlin.Int))`(`telephonyManager:` `[TelephonyManager](/reference/kotlin/android/telephony/TelephonyManager)!`, `request:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `failureCode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when a USSD request has failed to complete. |\n\nPublic constructors\n-------------------\n\n### UssdResponseCallback\n\n```\nUssdResponseCallback()\n```\n\nPublic methods\n--------------\n\n### onReceiveUssdResponse\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onReceiveUssdResponse(\n telephonyManager: TelephonyManager!, \n request: String!, \n response: CharSequence!\n): Unit\n```\n\nCalled 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.\n\nUSSD responses are unstructured text and their content is determined by the mobile network operator.\n\n| Parameters ||\n|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `telephonyManager` | [TelephonyManager](/reference/kotlin/android/telephony/TelephonyManager)!: the TelephonyManager the callback is registered to. |\n| `request` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the USSD request sent to the mobile network. |\n| `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. |\n\n### onReceiveUssdResponseFailed\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onReceiveUssdResponseFailed(\n telephonyManager: TelephonyManager!, \n request: String!, \n failureCode: Int\n): Unit\n```\n\nCalled when a USSD request has failed to complete.\n\n| Parameters ||\n|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `telephonyManager` | [TelephonyManager](/reference/kotlin/android/telephony/TelephonyManager)!: the TelephonyManager the callback is registered to. |\n| `request` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the USSD request sent to the mobile network. |\n| `failureCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): failure code indicating why the request failed. Will be either [TelephonyManager.USSD_RETURN_FAILURE](/reference/kotlin/android/telephony/TelephonyManager#USSD_RETURN_FAILURE:kotlin.Int) or [TelephonyManager.USSD_ERROR_SERVICE_UNAVAIL](/reference/kotlin/android/telephony/TelephonyManager#USSD_ERROR_SERVICE_UNAVAIL:kotlin.Int). |"]]