在 Intent.ACTION_NEW_OUTGOING_CALL 的 BroadcastReceiver 内发出 HttpClient 请求

发布于 2024-08-20 16:45:47 字数 737 浏览 1 评论 0原文

我正在尝试为我的 Android 手机编写一个类似于 Google Voice 的服务:它将拦截拨出的电话,用我从网络请求中查找的号码替换最初拨打的号码。

我知道可以使用请求 Intent.ACTION_NEW_OUTGOING_CALL 广播的 BroadcastReceiver 转接拨出电话,如 Android 源代码所示:

https://android.googlesource.com/platform/packages/apps/Phone/ +/gingerbread-release/src/com/android/phone/ProcessOutgoingCallTest.java

我的问题是,如何礼貌地执行长时间运行的任务,例如查找 setResultData(...) ; 使用网络请求?

Google Voice 以某种方式执行此请求。如何?他们是否取消原来的拨出呼叫并使用自定义的 InCallScreen 活动?我不这么认为,因为使用 Google Voice 时的通话 UI 与手机的 UI 相匹配(我在 Cliq、MT3G 和 Droid 上尝试过)。

I'm trying to write a service for my Android phone that is similar to Google Voice: it will intercept outgoing calls, replacing the originally dialed number with a number that I look up from a web request.

I know that outgoing calls can be diverted using a BroadcastReceiver that requests the Intent.ACTION_NEW_OUTGOING_CALL broadcast as demonstrated in the android source code here:

https://android.googlesource.com/platform/packages/apps/Phone/+/gingerbread-release/src/com/android/phone/ProcessOutgoingCallTest.java

My question is, how do I politely perform a long-running task like looking up the number for setResultData(...); using a web request?

Google Voice performs this request, somehow. How? Do they cancel the original outgoing call and use a custom InCallScreen Activity? I don't think so, because the in-call UI when using Google Voice matches the phone's UI (I have tried it on Cliq, MT3G, and Droid).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

π浅易 2024-08-27 16:45:47

我通过取消原始拨出呼叫、发出 Web 请求(同时显示我自己的“请稍候”对话框活动),然后创建另一个拨出呼叫来解决该问题。

不过,我对其他解决方案持开放态度。

I worked around the problem by indeed canceling the original outgoing call, making the web request (while showing my own "please wait" dialog activity), and then creating another outgoing call.

I'm open to other solutions though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文