It is necessary to make sure that the music continues to play during the transition to all activities. I use this code for sounds
MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); MediaPlayer click = MediaPlayer.create(this, R.raw."Нужная музыка"); click.start();
The most primitive way is to make an instance of the class static, which is responsible for working with audio and working with it in any Activity. Here's an example of a simple music player I was making. This is, of course, a bad way, and in fact it is desirable to use Service for this purpose.