Reputation: 49
I have 2 activities A and B. A has a recyclerView with list of songs. When i click one command goes to B and it starts playing it. B has an onCompletionListener()
so it changes and plays song automatically. When one hovers back to activity A, name of currently playing song is displayed in a textView there. Problem is that when a song is is changed in background, the textView can't be automatically updated.
One solution I had thought is making that textView static and change it from OnCompletionListener in B but I don't find that efficient. Is there a better way of doing that.
Upvotes: 3
Views: 58
Reputation: 41
There are several ways to implement this:
Upvotes: 1
Reputation: 435
If you're newbie in Android, the easiest (and fastest) way to create a communication channel between Android components is using a bus like EventBus
You just have to create a class containing the informations, then your activities will subscribe to a bus and they will send and receive these objects each other very easily
Upvotes: 1