Destroying the media player when user leaves the screen. (Android Studio- Java) -
this question has answer here:
- android mediaplayer stop , play 4 answers
i want stop background music when user clicks on exit button , direct main screen. missing in code below?
public void addlisteneronbutton() { final context context = this; exitbutton = (button) findviewbyid(r.id.exit); exitbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent intent = new intent(context,games.class); startactivity(intent); player.stop(); player.release(); } }); }
you can check answer of similar question, maybe solved problem: android mediaplayer stop , play
Comments
Post a Comment