How to keep a service running to listen for incoming and outgoing calls

by David_Fisher » Thu, 07 Oct 2010 06:40:34 GMT

Sponsored Links
 Hi, how should I create a service that would keep on running in the
Background and listen for incoming and outgoing calls? I don't want
the service to die at any point in time. I have created a Broadcast
Receiver in my service class that is set for
ACTION_PHONE_STATE_CHANGED action. In my BroadcastReceiver, I have set
up a PhoneStateListener that would listen for changes in phone states.
Is this the right approach? Thanks.


How to keep a service running to listen for incoming and outgoing calls

by Mark Murphy » Thu, 07 Oct 2010 06:56:11 GMT


That is redundant. ACTION_PHONE_STATE_CHANGED reports the same events
as the PhoneStateListener. Just use the ACTION_PHONE_STATE_CHANGED
BroadcastReceiver. You should not need a Service.

Mark Murphy (a Commons Guy)  |  | 

_Android Programming Tutorials_ Version 3.0.1 Available!


Sponsored Links

How to keep a service running to listen for incoming and outgoing calls

by Kumar Bibek » Thu, 07 Oct 2010 13:52:02 GMT

 Yeah. This is fine I guess. Are you stuck somewhere?


Other Threads

1. Why different behaviour when exiting app using BACK and HOME ?

Hi all,

I know this probably was discussed here before, but I can only find
bits of info.

Say a user runs my app from the HOME screen.
The app has 3 tabs. Say he/she selectes a different tab,
so he/she is in a different screen (same task).

Now - if the user presses BACK - the device returns to the HOME
If the user launches my app again - the default tab is shown.

BUT - if the user presses HOME - the device returns to the HOME screen
If the user launches my app again - the OTHER tab is shown.

I understand (sort of) the logic - BACK returns to previous app,
popping my app
from the history stack, so when launched again - it is started from
But this is confusing my customers - they say it's a bug !
They dont understand the different between two keys doing the same
as far as they see (returning to HOME).

Moreover - I see a different behavior with the built-in DIALER app - I
change tabs,
press HOME, launch the app again - and it starts with the default tab.

Can I imitate this ?



2. What's slow on Android?

Hello Android developers,

We are building an Android-based device, and would like to know what we should 
try to improve in terms of performance. If you can have just 3 things be much 
faster, what will they be?

.... please be specific (instead of "graphics is too slow", something like 
"drawing red poker dots on translucent canvas is slow")

.... and why are they important (a real-world use case would be good).




3. HTML login form works in Android browser and fails with WebView - Android bug ?

4. Is ADP1 still available for purchase by developers ?

5. EVIL SPAM Interested CRM on Android ?

6. (OT) Is the combination of Android Market and Google Checkout a joke?

7. OFF TOPIC Update UK G1 not showing paid apps