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

Bosah Chude
  • 3,670
  • 2
  • 22
  • 22
Michael Frans
  • 613
  • 3
  • 23
  • 49
  • 1
    possible duplicate of [How is it possible to do USSD requests on Android?](http://stackoverflow.com/questions/5477597/how-is-it-possible-to-do-ussd-requests-on-android) – Chris Stratton Aug 29 '11 at 01:02

2 Answers2

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" /
EC84B4
  • 7,676
  • 4
  • 23
  • 34
Bosah Chude
  • 3,670
  • 2
  • 22
  • 22
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" />
user3469914
  • 79
  • 1
  • 1