0

I have a music player Activity in my app.

The problem is that, if the user switch to other Activity inside my app, the music keeps playing, but if later he returns to the music player Activity, everything resets(song's title, duration...) except the music itself.

Is there a way to make an activity keep running?(not by using a service).

Guilherme Gregores
  • 1,050
  • 2
  • 10
  • 27
Raz
  • 160
  • 1
  • 4
  • 14
  • Long answer short: no. If you check the myriad of open source media players for android, you'll see that all use a service to play the audio – Augusto Feb 18 '13 at 13:52
  • why do you not want to use a service? I don't get the point. – Prateek Feb 18 '13 at 13:52
  • Because my music player is based on one activity and now ill have to start splitting it to a service... – Raz Feb 18 '13 at 13:53
  • **If the music keeps on running when user goes elsewhere**, and when he comes back, everything other than music resets...... Then it means that you are not using onCreate, onPause, onResume methods correctly according to your needs. –  Feb 18 '13 at 14:25

1 Answers1

0

Take a look here it might help you.

How to mute and unmute it on the onPause and onResume

Use the onPause() and onResume() for that.

Community
  • 1
  • 1
Guilherme Gregores
  • 1,050
  • 2
  • 10
  • 27