- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
根据 Android 开发人员博客上的这篇博文,更改拨出电话号码应该是可行的: http://android-developers.blogspot.com/2011/01/processing-ordered-broadcasts.html
问题是它对我不起作用,我的代码:
String action = intent.getAction();
if (Intent.ACTION_NEW_OUTGOING_CALL.equals(action)) {
// Try to read the phone number from previous receivers.
String phonenumber = getResultData();
if (phonenumber == null) {
// We could not find any previous data. Use the original
// phone
// number in this case.
phonenumber = intent
.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
}
String reformatedNumber = reformatNumber(phonenumber);
setResultData(reformatedNumber);
}
即使我重新格式化号码,我调用的电话号码也是被调用的号码。
有什么见解吗?
我的 list 中有这些权限:
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
奇怪的是,当我调用电话簿中未存储的号码时,我有一项服务试图弄清楚我在调用谁,我必须按对话框中的“调用”按钮才能完成电话。然后我的代码就可以工作了,但是当我通过电话簿给某人打电话时,或者如果我禁用了查找服务,它就不起作用了。
最佳答案
来自您提到的博文:
We have actually observed phones with a priority 0 receiver for the NEW_OUTGOING_CALL intent installed out of the box (this will be the last one that is called after all others) that completely ignores previous result data which means that, in effect, they disable any useful processing of ACTION_NEW_OUTGOING_CALL (other than canceling the call, which would still work). The only workaround for this is to also run your receiver at priority 0, which works due to particularities of running 2 receivers at the same priority but, by doing that, you break one of the few explicit rules for processing outgoing calls:
“For consistency, any receiver whose purpose is to prohibit phone calls should have a priority of 0, to ensure it will see the final phone number to be dialed. Any receiver whose purpose is to rewrite phone numbers to be called should have a positive priority. Negative priorities are reserved for the system for this broadcast; using them may cause problems.”
您是否遇到这样一个事实,即在手机上您的代码被提供者安装的优先级为 0 的 Intent 忽略了?您也可以通过将优先级设置为 0 来对此进行测试。
关于java - 更改去电号码,添加前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5052323/
我是一名优秀的程序员,十分优秀!