所以我试图通过Intent.ACTION_DIAL
发送一个以#ie结尾的号码,例如*123#
。但是当Android Dialer应用程序启动时,只有*123
(#缺失)。
我使用以下代码来触发Android的拨号应用程序。
Uri number = Uri.parse("tel:*124#");
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
context.startActivity(callIntent);
期待的谢谢!!
答案 0 :(得分:3)
您需要正确编码哈希标记(#)。在你的URL请求中,它应该是%23,所以用%23替换它就可以了。
Uri number = Uri.parse("tel:*124%23");
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
context.startActivity(callIntent);
您也可以让URI执行编码:
String encodedPhoneNumber = String.format("tel:%s", Uri.encode("*1234#"));
Uri number = Uri.parse(encodedPhoneNumber);
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
context.startActivity(callIntent);
答案 1 :(得分:1)
答案可能与此链接有关
initiate a phone call on android with special character #
这条线可能是关键
Uri.parse("tel:"+Uri.encode("*124#"));