Trocando um mp3

Top  Previous  Next

import android.media.MediaPlayer;

 

public class Splash extends Activity {

 

 MediaPlayer player;  

 

 @Override

 protected void onCreate(Bundle savedInstanceState) {

 

         super.onCreate(savedInstanceState);

         setContentView(R.layout.splash);

 

         player = MediaPlayer.create(Splash.this, R.raw.som);

         player.start();

 }

 

 @Override

 protected void onPause() {

    super.onPause();

     player.release(); // importante para liberar os recursos

 }

}