gpt4 book ai didi

java - 更改去电号码,添加前缀

转载 作者:太空狗 更新时间:2023-10-29 12:57:12 25 4
gpt4 key购买 nike

根据 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com