I am implementing a timer in my application which checks an alarm all the time.This timer values am checking in my home page and showing alerts telling how much time left..How can i show these messages when i am in different Activities ?
I am implementing a timer in my application which checks an alarm all the
Share
One way would be to add your timer check code to a Fragment with no UI and use that Fragment in your various activities.
If your dialog box doesn’t interact with your activity then you can start a TimerTask in a subclass of the Application object that checks your timers as often as you need. Then when a timer needs to go off, you can start a new activity that simply displays the alert dialog. Since you’re starting it from the Application (which subclasses Context), you need to set the NEW_TASK flag and theme the activity to be a “dialog”. You could even make the whole activity the dialog instead of starting the dialog in onStart()