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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With