sending USSD code Android

一个人想着一个人 提交于 2019-12-12 13:23:05

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/11157828/sending-ussd-code-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!