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.
精彩评论