BroadcastReceiver to log PhoneState during of my activity

by Mak » Sun, 15 Mar 2009 11:07:59 GMT

Sponsored Links
I'd like to log some telephonyManager and phoneState events as
onCellLocationChanged and onCallStateChanged.. during my activity.
Cause i need this for more than one activity,  i created an
broadcastReceiver that receives broadcasts, when something special in
my activities happen.

But my problem is that i can't define a telephonyManager in the
like in an activity.
Why wont the following work in?

TelephonyManager tmanager = (TelephonyManager)
tmanager.listen( new PhoneStateListener(){

        public void onCallStateChanged(int state, String incomingNumber) {
                super.onCallStateChanged(state, incomingNumber);
                callstate =  state;

}, PhoneStateListener.LISTEN_CALL_STATE);

Why is getSystemService(String) undefined for a broadcastReceiver?
Where is my fault?
Thanks for an answer.

Other Threads

1. NotePad sample app fails to install over the web

It installs fine on my G1 using adb, but even after compiling a
release version, and signing it properly, if I try downloading and
installing from my web server, it fails.

The only error message I get on my G1 is "Install unsuccessful."

I've made sure to uninstall the app before trying to install it from
the web.

I'm using OSX, and the latest version of the SDK.


2. Anyone mind testing quickly?

Anyone mind testing this on a real phone for me (before the marketplace
launch tomorrow)? It's a basic tip calculator.

The main thing I'm not sure will work are the blue arrow buttons to the
right of the text fields. You should be able to touch them to modify values
in the calculator. Appreciate it!


3. GLUT or something like that in Android

4. insertImage -- transparent portions of image are now black

5. Cell IDs by cell phones

6. Developing GPS Application on Android

7. G1 GPS receiver turn on and turn off