安卓:简单的USSD拨号应用简单、USSD

2023-09-06 01:11:51 作者:丶最后一次颓废

我创建了一个简单的拨号器,快速帮我拨打移动服务提供商的服务,如检查空气平衡,从供应商获得互联网设置

I have created a simple dialer to quickly help me dial mobile provider services like checking air balance, getting internet settings from the provider

//example
phoneNum[1] = "*144#";

当我点击检查平衡它说拨号

When i click a button for checking balance it says Dialing

 Dialing *144

* 144,并注意哈希是不存在的,但它应该用作USSD code。如果散列可用,返回的平衡,而不是调用的。我如何哈希添加到阵列?

*144 and notice the hash isn't there but it should operate as ussd code if the hash was available and return the balance instead of calling. How do i add the hash to the array?

推荐答案

您应该逃脱%#符号23

You should escape the # symbol with %23

//例子 PHONENUM [1] =* 144;

//example phoneNum[1] = "*144";

String encodedHash = Uri.encode("#");
startActivity(new Intent("android.intent.action.DIAL",
              Uri.parse("tel:"+ phoneNum[1]+ encodedHash)));

对于捕获的反应,你应该用

As for the catching the response, you should experiment with

startActivityForResult(new Intent("android.intent.action.CALL", 
                   Uri.parse("tel:"+ phoneNum[1]+ encodedHash)), 1);
@Override
protected void onActivityResult(int requestCode, int resultCode,Intent data) {
    view.setText("USSD: " + requestCode + " " + resultCode + " " + data);
}

和看会是回报你。