samples/Support4Demos/src/main/java/com/example/android/supportv4/media/Playback.java
private void tryToGetAudioFocus() {
        Log.d(TAG, "tryToGetAudioFocus");
        if (mAudioFocus != AUDIO_FOCUSED) {
            int result = mAudioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC,
                    AudioManager.AUDIOFOCUS_GAIN);
            if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
                mAudioFocus = AUDIO_FOCUSED;
            }
        }
    }
/**
     * Try to get the system audio focus.
     */
Try to get the system audio focus.
Try to get the system audio focus .
private void tryToGetAudioFocus() {
        Log.d(TAG, "tryToGetAudioFocus");
        if (mAudioFocus != AUDIO_FOCUSED) {
            int result = mAudioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC,
                    AudioManager.AUDIOFOCUS_GAIN);
            if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
                mAudioFocus = AUDIO_FOCUSED;
            }
        }
    }
private void tryToGetAudioFocus ( ) { Log . d ( TAG , "tryToGetAudioFocus" ) ; if ( mAudioFocus != AUDIO_FOCUSED ) { int result = mAudioManager . requestAudioFocus ( this , AudioManager . STREAM_MUSIC , AudioManager . AUDIOFOCUS_GAIN ) ; if ( result == AudioManager . AUDIOFOCUS_REQUEST_GRANTED ) { mAudioFocus = AUDIO_FOCUSED ; } } }
Try to get the system audio focus.
Try to get the system audio focus .