문제

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

도움이 되었습니까?

해결책

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);
        }
    });

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top