Ahh, thanks Marc. I have been using Intent.ACTION_NEW_OUTGOING_CALL to
determine if an outgoing call was being placed.
I wasn't aware of the TelephonyManager.ACTION_PHONE_STATE_CHANGED
Intent.
Won't it fire for both incoming and outgoing calls?
Seems strange the 2 Intents are not co-located.

But assuming I want some action to occur during the lifetime of a
phone call.
What's the best way of ensuring it isn't killed by the system?
If I start a service, which monitors the call, I can't guarantee it
won't be killed.
What's the best option?


On Aug 11, 10:01 pm, Mark Murphy <[email protected]> wrote:
> On Wed, Aug 11, 2010 at 5:08 AM, William Ferguson
>
> <[email protected]> wrote:
> > In particular, how should you keep a service alive that needs to
> > listen and respond to phone state events?
>
> Don't use a service. Use a manifest-registered BroadcastReceiver
> watching for ACTION_PHONE_STATE_CHANGED:
>
> http://developer.android.com/reference/android/telephony/TelephonyMan...
>
> > And on phone state events, why is it that responding to an inbound
> > phone call requires a phone state listener, but an outbound phone call
> > can be responded to via a broadcast receiver.
>
> According to the documentation, ACTION_PHONE_STATE_CHANGED works for
> incoming calls:
>
> "If the new state is RINGING, a second extra EXTRA_INCOMING_NUMBER
> provides the incoming phone number as a String."
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android 2.2 Programming Books:http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to