Hello,
I've been struggling with this beast and it seems that I can't take
control over it. What I want is a PhoneStateListener subclass which
listens for a LISTEN_CALL_STATE.
First I tried to make one instance on RECEIVE_BOOT_COMPLETED, leave it
attached and then when the event comes - the listener to start a
service which will do something for a while and consequently calls
stopSelf(). For this purpose I had to keep a reference to a Context
(getApplicationCopntext()) in the listener, but this thing didn't seem
to work as expected, if I leave it for a longer period - the listener
is simply gone - so none of the things I want ever happen.
My second approach, which is not what I really want is to start a
local service, create the listener in it and leave it alive until the
user stops it. This approach has two limitations, the resources which
should be spent for a service which just sits and keeps a reference to
a PhoneStateListener, and the other thing is that it doesn't seem to
work as expected, again. What I do is to keep a reference to the
listener in a static variable of my PhoneStateListener subclass, just
to know that it is attached and the service is running (this can be
controlled from another activity), but it looks that even though my
instance is alive (and my service running), and previously attached
via listen method to the TelephonyManager, it stops receiving the
events after half a day, or so.

I'm not sure if these approaches are correct for what I want. It could
have been easier if there was intent for incoming call. I tried to
trace what TelephonyManager does with the listeners but couldn't get
that deep in the source. Any help?

-- 
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