android在URI中用#开始一个电话呼叫意图

时间:2014-03-06 05:30:49

标签: android android-intent phone-call

我尝试按照以下方式拨打电话,我仍然继续从已拨打的号码中删除"#" 。请参阅下面的代码...在将字符串的内容打印到控制台时,最后的#转换为%23。我正在测试三星S4手机,然后运行USSD代码错误。手机或下面的代码是否有问题

Intent phoneCallIntent = new Intent(Intent.ACTION_CALL);    
phoneCallIntent.setData(Uri.parse("tel:" + Uri.encode("*222*"+ rechargeNumber + "#");));        
startActivity(phoneCallIntent);

2 个答案:

答案 0 :(得分:0)

不要使用Uri.encode()

使用以下代码。我认为它会对你有帮助。

String uri = "tel:" +"*222*"+ rechargeNumber + "#" ;
 Intent intent = new Intent(Intent.ACTION_CALL);
 intent.setData(Uri.parse(uri));
 startActivity(intent);

答案 1 :(得分:0)

你正在寻找的是android.intent.action.CALL_PRIVILEGED。 这可能对您有所帮助 using android dialer in 3rd party app