Search code examples
androidandroid-audiomanager

why is abandonAudioFocus not working in Android Music app


Im using this code to get AudioFocus and it works ok with
Android Music app ( the one preinstalled )

int result = audioManager.requestAudioFocus(meService, AudioManager.STREAM_MUSIC,AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);    

However when i release it with this code

audioManager.abandonAudioFocus(meService);

The Android Music app ( the one preinstalled ) does not continue playing.

if i use the AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK it works
but Android Music app is not lowering the volume enough.

Any ides why Android Music app is not resuming playback?

im using api8 and using the onAudioFocusChange


Solution

  • After trying 4 players non of them are ducking. I might be doing something wrong and would like to see that. I answer my own question that we have to live with this.