Well, why doesn't it?
From my understanding, finish() destroys the entire activity, so it should also destroy the running media player.
Here is my code:
MediaPlayer ourSong;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
ourSong = MediaPlayer.create(this, R.raw.hungat);
ourSong.start();
Thread timer = new Thread() {
@Override
public void run() {
try {
sleep(5000);
} catch (InterruptedException e){
e.printStackTrace();
}finally {
Intent i1 = new Intent("android.intent.action.MAINACTIVITY");
startActivity(i1);
}
}
};
timer.start();
}
@Override
protected void onPause() {
super.onPause();
finish();
}
}