I need a class with a Timer that chekcs the status after regular intervals. If the status is false, should inform the calling UI class. The Timer class will be started and stopped from the UI Class (Activity) only.
I am confused - don't know what will be best to implement the Tiemr class as. Should it be implemetned as a Service, or as as AsyncTask (as it will be running in background only) or something else. And how to inform the UI class about change of status from the Timer Class. Like if the status is found to be false, then only inform the Timer class else ignore and keep on checking on regular intervals.
Can anyone guide me for this ? I am a newbie in Android and couldn't make what to use and implement. Any help, guidance is highly appreciated.
Thanks Swastik. Wondering bout just 1 thing. In new ServiceHandler(sh) why are you passing the object of Service Handler itself. Shouldn't that be "this" instead of "sh" as the class implements UINotifier & ServiceHandler needs an object of UINotifier.
Is it your mistake or I am getting it wrong ! Can you please clear it .
Swastik, instead of UINotifier I had to use Handler. UINotifier notifies it properly, but I als have ASyncTask in my Activity and with that all was throwing exception for "Can't hanlde .... Looper.prepare..". Use of Handler instead of Timer & TimerTask and Handler.Callback instead of UINotifier did the work smoothly.