I am working on an android application, where there are 4 activities. Activity1 is main activity and there are different buttons on that activity which can open other activities. Other 3 activities can also open each other. There is a thread running in Activity1 which returns some counter. I need to show that counter on all activities.
At an specific time, the thread doesn’t know which activity is at top. What is the right way to control this scenario, such that thread output should update on all activities, no matter which one is at top?
I would have that counter on a Service and I would send updates through broadcast intent.
Each
Activitywill register a listener to that intent on theonStartmethod and unregister it ononPause. This way the update will reach only the Activity that is on screen.