How to run USSD commands on android?
Asked Answered
C

2

13

has anyone know how to runs USSD command for checking phone's credit balance (the number is *123#) and get the result (the credit balance) for further processing?? thankss

Curassow answered 29/8, 2011 at 0:50 Comment(1)
possible duplicate of How is it possible to do USSD requests on Android?Intuitivism
C
25

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" /
Ciao answered 29/8, 2011 at 14:46 Comment(2)
can replace "android.intent.action.CALL" by Intent.ACTION_CALL Unqualified
you should call permission in to your monifest by adding this line: <uses-permission android:name="android.permission.CALL_PHONE" />Shimmery
H
5

You can use "%23" instead of "#" :

String ussdCode = "*" + "123"+"%23";
startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + ussdCode)));

You should also add permission to your Manifest file:

<uses-permission android:name="android.permission.CALL_PHONE" />
Hiragana answered 28/3, 2014 at 7:54 Comment(1)
is there no way to parse the ussd result,i need to capture the balance of my phone at regular interval,Lockwood

© 2022 - 2024 — McMap. All rights reserved.