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/TelephonyManager.html#ACTION_PHONE_STATE_CHANGED

> 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/commonsguy
http://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