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 be开发者_StackOverflow社区come 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!
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.
精彩评论