BroadcastReceiver to log PhoneState during of my activity

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


Sponsored Links
 Hi.
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
broadcastReceiver
like in an activity.
Why wont the following work in?

.............
TelephonyManager tmanager = (TelephonyManager)
                                      getSystemService
(Context.TELEPHONY_SERVICE);
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.
Mak
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. getThumbnails through droid incredible phoneStorage mount

I used the following method to access droid incredible onboard memory
data:

photosCursor =
mActivity.managedQuery(MediaStore.Images.Media.getContentUri("phoneStorage"),
photoColumns, null, null, MediaStore.Images.Media.DATE_MODIFIED + "
DESC");

How will it effect the following methods, right now it looks up
thumbnails with wrong id:

MediaStore.Images.Thumbnails.getThumbnail(activity.getContentResolver(),
Long.valueOf(id), MediaStore.Images.Thumbnails.MINI_KIND,
thumbBitmapOptions );

or

MediaStore.Video.Thumbnails.getThumbnail(activity.getContentResolver(),
Long.valueOf(id), MediaStore.Video.Thumbnails.MINI_KIND,
thumbBitmapOptions);


I understand these methods are also somehow linked with phoneStorage
URI ?

Thanks

-- 

2. Open tablet device? And whatever happened to the TI Blaze tablet?

Hello,

I'm looking for an Android tablet device that is open, i.e. flashing
of the OS is supported by the manufacturer.  I see that there are a
variety of dev boards that support this as well as the Nexus One, but
are there any tablets with this functionality?  Also has anyone heard
anything about the TI Blaze tablet recently?

Thanks!

Patrick Keith-Hynes
University of {*filter*}ia

-- 

3. How to play audio file in android ?

4. Paging htc evo users part II (All about quadrant and linpack)

5. Code please : Youtube video player API for my Android

6. estate properties

7. estate properties