Since requestAudioFocus(AudioManager.OnAudioFocusChangeListener l, int streamType, int durationHint)
is deprecated in API O , how do you set audio focus change list
To gain the focus use below (It will pause other player) :
mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
mAudioManager.requestAudioFocus(null,AudioManager.STREAM_MUSIC,AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
To leave the focus use below (It will resume that player) :
mAudioManager.abandonAudioFocus(null);