Search code examples
androidbroadcastreceiver

How to implement BroadcastReceiver to do different tasks depends on time interval


My application needs to show some notifications for schedules (like Alarm), based on time interval.

For example:

There are 4 tasks I have setted in my application, like

Task A -> from 10:00 to 13:00
Task B -> from 15:10 to 16:00
Task C -> from 17:00 to 17:30
Task D -> from 20:00 to 23:30

So notification should be shown as

at 10:00 Task A has started

at 13:00 Task A has ended

at 15:10 Task B has started

... and so on.

How can I implement this? Can you please provide some tutorials related to it? And if there are more than one way, which is the best way to do this?


Solution

  • Have a look at TimerTask

    And there is some code on how to use it:

    http://enos.itcollege.ee/~jpoial/docs/tutorial/essential/threads/timer.html