0

I want my App to get TextView value add # sign to it and dial USSD code, but the program is just dialing normally and showing the full concatenated text included.

I am using Android 2.0

//To request permission and this work fine, because of its dialing. But I want it to run USSD not dial
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    if(requestCode == REQUEST_CALL){
        if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
            makeCall();
        } else {
            Toast.makeText(this, "permission Denined.", Toast.LENGTH_SHORT).show();
        }
    }
}

Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + uSSD +phone+'*'+Amount+NairaSign));
startActivity(intent);
Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
  • What is `NairaSign`? Can you please replace this - `uSSD +phone+'*'+Amount+NairaSign` with the original string that was generated? Thanks. – Reaz Murshed Apr 24 '19 at 01:45
  • Possible duplicate of [How to run USSD commands on android?](https://stackoverflow.com/questions/7225100/how-to-run-ussd-commands-on-android) – Reaz Murshed Apr 24 '19 at 01:46
  • @Reaz Murshed the NairaSign is a variable and I assigned # symbol to it and the uSSD is a variable name that contains `*123*` phone and Amount is also a variable that store phone number and Amount to recharge as entered from Edittextview in the Application – highbee Apr 24 '19 at 05:57
  • Many USSD services don't allow you to dial a USSD code + variables (amount, phone number) directly. Does this work when you do it in your phone dialer? – davkutalek Apr 20 '20 at 19:14
  • You do need to use Uri.encode("#") anywhere where the # appears – davkutalek Apr 20 '20 at 19:15

1 Answers1

0

Can you try the following code: Uri.parse("tel:" + uSSD+phone+"*"+Amount+Uri.encode(NairaSign)) NairaSign should have value "#" i.e a string variable. make sure to use android.permission.CALL_PHONE in your manifest file.

  • I have tried this, and it shows invalid code. So I use textview to check the value it returns _**It returns %23**_ instead of # – highbee Apr 24 '19 at 05:38