Code example for AudioManager

Methods: unregisterMediaButtonEventReceiver

0
            Log.d(TAG, "Stopping foreground.");
            this.stopForeground(true);
            Log.d(TAG, "Unregistering noisy audio receiver.");
            super.unregisterReceiver(this.noisyAudioReceiver);
            Log.d(TAG, "Unregistering remote audio control receiver.");
            this.audioManager.unregisterMediaButtonEventReceiver(this.remoteControlReceiverName);
            Log.d(TAG, "Stopping service.");
            super.stopSelf(); 
        } 
    } 
 
    private void notifyUser(String message) {
        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
    } 
 
    @Override 
    public void onDestroy() { 
        this.releaseMediaPlayer();
        super.onDestroy(); 
    }