Reputation: 28349
I'm guessing the answer is no, but just in case, I'm curious if there's any way to write a receiver that would launch an app when the phone starts to receive a call. Even something as simple as a dialog activity that says "your phone is ringing". Or is the phone always going to suppress any other app that's trying to run?
Upvotes: 1
Views: 157
Reputation: 48871
You can register a BroadcastReceiver
to 'listen' for...
TelephonyManager.ACTION_PHONE_STATE_CHANGED
You can then check EXTRA_STATE
for CALL_STATE_RINGING
.
However, I'm not sure why you would want to 'launch an app'. You say...
Even something as simple as a dialog activity that says "your phone is ringing".
My phone already tells me when my phone is ringing - I get custom ringtones depending on who is calling me and I get to see their picture too. I'm not quite sure what you're trying to achieve here.
Upvotes: 2
Reputation: 1275
I think this question might have already been asked here on SO:
Catch a Ring event
First, I'm not an Android programmer, but I'm pretty sure you can do what you are asking.
Essentially the Android OS is running the device and processing incoming calls (smart phones are more computer than phone nowadays). I hypothesize that embedded in the OS is a series of "events" or "state changes/flags" that the OS uses to interrupt other running programs, that switches the focus to the phone application when the hardware notices an incoming call.
I believe that detecting and reacting to the event is possible, as the phone is running daemon processes in the background while the phone call is happening. I read most of the blog entry that this other SO post links to, and it looks like some moderately complex stuff, but not impossible.
Good luck to you!
Upvotes: 0