tags:

views:

48

answers:

1

I have a class that is essentially a message manager (a singleton) that has a timer that polls for status. (statusPollerTask is just a derived class of TimerTask that has the run() defined)

timer.scheduleAtFixedRate(this.statusPollerTask, 0, 1000);

Several Activities register themselves with the msg-man for updates (observer pattern style) as they become visible. Works fine, except if the user presses the Home button and minimizes the app. Sometimes the timer keeps polling other times it doesn't. I need to maintain the polling even when the app is not visible. I feel like I'm just missing something simple here. Any help is appreciated!

+2  A: 

You should use the Alarm Manager

This Class will ensure that your activities are called even if they are destroyed they will be created again.

Jason
@Jason, sorry I'm confused. I'm not worried about Activities being around, its that sometimes the timer stops the polling defined in it's timertask's run method. With an Alarm Manager, since I need to feed it an Intent doesn't it want to recreate the whole Activity? Or can I have it call into a particular method?
cbursk