audio manager audio focus kotlin code example
Example: request audio focus android
AudioManager.OnAudioFocusChangeListener audioListener = new AudioManager.OnAudioFocusChangeListener() {
@Override
public void onAudioFocusChange(int i) {
}
};
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.requestAudioFocus(audioListener , AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
if (focusChange == AudioManager.AUDIOFOCUS_GAIN) {
}else if (focusChange == AudioManager.AUDIOFOCUS_REQUEST_FAILED) {
}