安卓:简单的USSD拨号应用 [英] Android:Simple USSD Dialer Application

查看:151
本文介绍了安卓:简单的USSD拨号应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

和看会是回报你。

这篇关于安卓:简单的USSD拨号应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆