Created:

MediaPlayer mp = new MediaPlayer(); mp.setDataSource(FILENAME); mp.prepare(); 

launched:

 mp.start 

Plays even when Activity onDestroy ()
In the newly opened Activity, mp is created and music plays on top of an already running mp.

Question: how to resume management of an already running mp in a newly opened Activity (after onDestroy ())?

    2 answers 2

    Either take out the launch of MediaPlayer in Service , or destroy the MediaPlayer in onDestroy() .

      It will play until you do mp.stop (), or mp.reset (), or mp.release (), or the system will not kill it itself.

      In general, it is advisable to enter in Activity onDestroy (): mp.release () Then the player will stop and release the occupied resources.

      And in general, if there is a problem with the player, look at the diagram and immediately everything will be clear: http://developer.android.com/reference/android/media/MediaPlayer.html

      In order to manage the player from several activites, make the service and put the player there. Here's what you need to know: http://startandroid.ru/ru/uroki/vse-uroki-spiskom/162-urok-97-service-binding-serviceconnection.html http://startandroid.ru/ru/uroki/vse- uroki-spiskom / 163-urok-98-service-lokalnyj-binding.html