Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android:Simple USSD Dialer Application

Tags:

android

I have created a simple dialer to quickly help me dial mobile provider services like checking air balance, getting internet settings from the provider

//example
phoneNum[1] = "*144#";

When i click a button for checking balance it says Dialing

 Dialing *144

*144 and notice the hash isn't there but it should operate as ussd code if the hash was available and return the balance instead of calling. How do i add the hash to the array?

like image 349
Alphy Avatar asked Jan 18 '13 12:01

Alphy


1 Answers

You should escape the # symbol with %23

//example phoneNum[1] = "*144";

String encodedHash = Uri.encode("#");
startActivity(new Intent("android.intent.action.DIAL",
              Uri.parse("tel:"+ phoneNum[1]+ encodedHash)));

As for the catching the response, you should experiment with

startActivityForResult(new Intent("android.intent.action.CALL", 
                   Uri.parse("tel:"+ phoneNum[1]+ encodedHash)), 1);
@Override
protected void onActivityResult(int requestCode, int resultCode,Intent data) {
    view.setText("USSD: " + requestCode + " " + resultCode + " " + data);
}

and see what will that return you.

like image 127
Andrej Karadzic Avatar answered Nov 04 '22 01:11

Andrej Karadzic