Destroying the media player when user leaves the screen. (Android Studio- Java) -


this question has answer here:

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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -