开发者

Making an HttpClient request inside a BroadcastReceiver for Intent.ACTION_NEW_OUTGOING_CALL

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 dive开发者_StackOverflow中文版rted 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).


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜