Search code examples
androidphone-call

"#" not included while sending call (i.e. for mobile phone recharging) In android phone


I want to make recharge process just by entering the recharge number and add up 401 at the beginning and # at last eg: *401*12387263736748# . but call goes like: *401*12387263736748 without "#" included.

    RechargeRequestButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {

            RechargeCode = "*401*"
                    + RechargeCodeView.getText().toString()+"#";
            Intent RechargeingIntent = new Intent(Intent.ACTION_CALL, Uri
                    .parse("tel:"+RechargeCode));
            try {

                startActivity(RechargeingIntent);
                finish();
            } catch (Exception e) {
                Log.e("Exception", e.getMessage());
                Toast.makeText(getApplicationContext(), "Cannot make call",
                        Toast.LENGTH_SHORT).show();
            }
        }
    });

Solution

  • Just replace "#" with Uri.encode("#") or "%23". But I will not recommend this, as this can cause some security issues.