How How to Do Ussd Requests on Android

How is it possible to do USSD requests on Android?

You can intercept the USSD reponse , In order to do that you need to implement IExtendedNetworkService.aidl interface which binds the service with PhoneUtils. It then can intercept any USSD response and you can read that in your app easily .
FYI
https://github.com/alaasalman/ussdinterceptor

How to run USSD commands on android?

You can run USSD codes in Android devices but you would be unable to parse the result in your application. This feature might be added to the Android SDK in the future but for now, you would have to look for an alternative.

USSD can be run using simple Call intents. See Example:

String ussdCode = "*" + "123" + Uri.encode("#");
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + ussdCode)));

as mentioned in the comments phone call permission is also required

<uses-permission android:name="android.permission.CALL_PHONE" /

Call (and get the response for) a USSD Code, in the background?

Android O(API level 26) adds a sendUssdRequest method to the TelephonyManager, which also includes a callback for getting the result for the request.

The docs.



Related Topics



Leave a reply



Submit