使Android的USSD通话 [英] Make USSD call in android
本文介绍了使Android的USSD通话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要首先检查平衡,我不得不拨打电话 * XXX#,然后我得到的多个选项的响应,从我输入后,特别是一些选择,我得到了平衡。
什么code我可以在Android应用使用相同?
拨号 * XXX * X#是给我的错误。
下面是我的code,工作正常的*#XXX电话:
字符串连接codedHash = Uri.en code(#);
字符串USSD =*+ EN codedHash + lCallNum + EN codedHash;
startActivity(新意图(Intent.ACTION_CALL,Uri.parse(电话:+ USSD)));
解决方案
这对我的作品:
私人乌里ussdToCallableUri(字符串USSD){ 串uriString中=; 如果(ussd.startsWith(电话:!))
uriString中+ =电话: 对于(字符C:ussd.toCharArray()){ 如果(C =='#')
uriString中+ = Uri.en code(#);
其他
uriString中+ = C;
} 返回Uri.parse(uriString中);
}
然后在工作code:
意图callIntent =新意图(Intent.ACTION_CALL,ussdToCallableUri(yourUSSD codeHere));
startActivity(callIntent);
To check the balance first i have to make a call *xxx# and then i get a response with the multiple options to choose from and after i input the particular number i get the balance.
What code can i use for the same in my android app?
Dialing *xxx*x# is giving me error.
Below is my code which works fine for the *xxx# calls:
String encodedHash = Uri.encode("#");
String ussd = "*" + encodedHash + lCallNum + encodedHash;
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + ussd)));
解决方案
This works for me:
private Uri ussdToCallableUri(String ussd) {
String uriString = "";
if(!ussd.startsWith("tel:"))
uriString += "tel:";
for(char c : ussd.toCharArray()) {
if(c == '#')
uriString += Uri.encode("#");
else
uriString += c;
}
return Uri.parse(uriString);
}
Then in work code:
Intent callIntent = new Intent(Intent.ACTION_CALL, ussdToCallableUri(yourUSSDCodeHere));
startActivity(callIntent);
这篇关于使Android的USSD通话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文