I am working on a music player app. One of the requirements I have is to display a media control bar at the bottom of the screen (with progress indicator and a stop button). This bar has to persist across the whole application while the music is playing in the background even when the user navigates between activities.
I would like some advice on how to best implement this, the key challenge for me being to find a solution to keep this control bar visible across all activities, 'floating' above the screens when the music is playing.
I am currently playing the music via an android Service using a MediaPlayer so the bar has to sync its state with the service.
After doing some research, I've found a few hints on what I could do, but none seem ideal:
One option I thought of, but it's not elegant, is for this control bar to be a fragment that I'll include in all my activities. When the activity starts, bind to the service to get the latest state and then use callback mechanism to get regular updates (via BroadcastReceiver).
Any better/other ideas?
Thanks.
Most non-intrusive way is the one you described. Or check:
How to implement a popup overlay that can be displayed over any other app in Android
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With