Code example for AudioManager

Methods: abandonAudioFocus

0
            mAM.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
    } 
 
    /** Abandons audio focus. Returns whether request was successful or not. */ 
    public boolean abandonFocus() { 
        return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAM.abandonAudioFocus(this);
    } 
 
    /**  
     * Called by AudioManager on audio focus changes. We implement this by calling our 
     * MusicFocusable appropriately to relay the message. 
     */ 
    public void onAudioFocusChange(int focusChange) {
        if (mFocusable == null) return;
        switch (focusChange) {
            case AudioManager.AUDIOFOCUS_GAIN:
                mFocusable.onGainedAudioFocus();
                break; 
            case AudioManager.AUDIOFOCUS_LOSS:
            case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
                mFocusable.onLostAudioFocus(false);