I am running into an issue in Android where I think I need to keep some sort of reference to a MediaPlayer object.
In my Activity I begin by instantiating the MediaPlayer object and I can begin playing chosen music. The problem lies when the screen rotates, the Activity gets destroyed, created again, and then I lose reference to the MediaPlayer (since nowhere do I save it). A new object gets created and the next time the user interacts with the phone, the music stops playing. What is the proper way of keeping a handle on it? Should I be? It’s not Serializable so I can’t put it in a onSaveInstanceState(Bundle).
Thanks for the help.
I would try putting the
MediaPlayerin a service, setting up a bind and control it from withing your application.