Question

I'm trying to send a USSD code through my cellphone, so I used an intent as many here suggested is the way to send the code. Unfortunately, every time I send the code it sends the same number *4355696753

the code I'm using to send the USSD is:

sendCode.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            String cUssd = ussdCodeEdTxt.getText().toString();
            String cToSend = "tel:*" + cUssd + Uri.encode("#");
            startActivityForResult(new Intent("android.intent.action.CALL",
                       Uri.parse(cToSend)), 1);

        }
    });

any ideas would be greatly appreciated

Was it helpful?

Solution

I think you may need to use Uri.encode("*") for the star as well

sendCode.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            String cUssd = ussdCodeEdTxt.getText().toString();
            String cToSend = "tel:" + Uri.encode("*") + cUssd + Uri.encode("#");
            startActivityForResult(new Intent("android.intent.action.CALL",
                       Uri.parse(cToSend)), 1);
        }
    });

OTHER TIPS

though this is an old post but, for those facing the same issue try this Uri.fromParts("tel", number eg = *222# , "#");

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top