Skip to content

Instantly share code, notes, and snippets.

@markojerkic
Created April 17, 2017 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markojerkic/06e6edd3c71d10f44d3a6109ec8b7c41 to your computer and use it in GitHub Desktop.
Save markojerkic/06e6edd3c71d10f44d3a6109ec8b7c41 to your computer and use it in GitHub Desktop.
AUDIOFOCUS_GAIN
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
AudioManager.OnAudioFocusChangeListener afChangeListener;
int res = audioManager.requestAudioFocus(afChangeListener, AudioManager.STREAM_MUSIC, // Music streaming
AudioManager.AUDIODOCUS_GAIN); // Permanent focus
if(res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
// Play the audio
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment