Search code examples
androidandroid-mediaplayerlifecycle

Where set media style notification bar after recreation musicplayer app


I'm programming a music player app. After changing the theme color, I recreate MainAcitivity. When the recovery is finished, my player continues playing the last track played.

MainActivity.getInstance().recreate();

My app uses the MediaBrowserService. After my app is available for the user again, the Pause/Play button should be set to Pause and further actions - as media style notification - should be set.

I think, the player continues playing due to the bundle objects savedInstanceState - but I don't set any object there.

Where is the correct place to set and put the state to show notification bar after recreation.

I implemented the MediaBrowserServicewith this manual. https://www.sitepoint.com/a-step-by-step-guide-to-building-an-android-audio-player-app/

Thank you for your help.


Solution

  • Solved by setting start of Service onStart() Methode like ->

    Intent intent = new Intent(getmContext(),BackgroundAudioService.class); startService(intent);