0

android developer

I have an application that play music from sd card using media player. In this application, I have a seekbar to indicate the music that being play. The seekbar run in thread, and updated while music is playing.

If a press the back button, the music is still playing as I want. But if I click the application again, the seekbar is back to 0. It means all instances are created the new one.

What I supposed to do, to save the instance of the media player when I press back button? What kind of implementation that I should do at onPause and onResume?

skolima
  • 31,963
  • 27
  • 115
  • 151

1 Answers1

1

you have to save the state of your application and then restore it using onRestoreInstanceState when your application start again. see here Saving Android Activity state using Save Instance State

Community
  • 1
  • 1
Sunny
  • 14,522
  • 15
  • 84
  • 129