In my application in every activity at the top I have a fragment with TextView
showing the current event that is taking place. It looks something like this:
--------------------
| Event name |
|------------------|
| |
| |
| |
| Activity |
| content |
| |
| |
| |
| |
| |
--------------------
I want to update the event name when the next event starts.
I'm using singleton pattern and in my Application I have the currentEvent
string that I show at every activity start. I keep the events in database and every event has start time.
What is the best way to update the event name. How can I schedule event that will update the text view based on the start time for the next event?
I did it something like @Jeffrey said but with some changes:
In the Application
class, in onCreate()
I get the current and the next event and create the handler just like @Jeffrey said, but in the run()
of the handler's Runnable
I send a broadcast.
I register a BroadcastReceiver
with the same IntentFilter
in each CurrentEvent
fragment. And in the onReceive()
method of the receiver I update the TextView
.