I've been trying to develop an application that has some background music in android studio, when I minimized the application/closed the application/put the application in the background the music oddly kept playing. It's my intention that the application doesn't make any sound when it is not visible.
Is there some way to completely mute an application when it goes into the background? All sounds are currently done using SoundPool.
So far I haven't tried much as I couldn't find usable information on what I'm trying to do.
use lifecycle method to pause resume background song
@Override
protected void onPause() {
super.onPause();
// pause your soundpool here
}
then on onResume
@Override
protected void onResume() {
super.onResume();
//resume that background song again
}