AudioManager unregisterMediaButtonEventReceiver - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AudioManager unregisterMediaButtonEventReceiver method.

This code example shows how to use the following methods:unregisterMediaButtonEventReceiver
	/** 
	 * Calls {@link AudioManager#unregisterMediaButtonEventReceiver(ComponentName)}. 
	 */ 
	public static void unregisterMediaButtonEventReceiver(AudioManager manager, ComponentName receiver)
	{ 
		manager.unregisterMediaButtonEventReceiver(receiver);
	} 
 
	/** 
	 * Calls {@link BackupManager#dataChanged()}. 
	 */ 
	public static void dataChanged(Context context)
	{ 
		new BackupManager(context).dataChanged();
	} 
 
	/** 
	 * Creates an audio focus listener that calls back to {@link PlaybackService#onAudioFocusChange(int)}. 
	 */ 
	public static void createAudioFocus() 
6
CodeRank
This code example shows how to use the following methods:abandonAudioFocus, unregisterMediaButtonEventReceiver
		mAudioService.registerMediaButtonEventReceiver(getEventReceiver());
	} 
 
	@Override 
	public void onPlaybackStopped() { 
		mAudioService.abandonAudioFocus(mAudioFocusChangeListener);
		mAudioService.unregisterMediaButtonEventReceiver(getEventReceiver());
	} 
 
	private ComponentName getEventReceiver() {
		if (mEventReceiver == null) {
			mEventReceiver = new ComponentName(mContext,
					BroadcastReceiver.class);
		} 
		return mEventReceiver;
	} 
} 
6
CodeRank
This code example shows how to use the following methods:abandonAudioFocus, unregisterMediaButtonEventReceiver
 
        public void unregister() 
        { 
            try 
            { 
                audio_manager.unregisterMediaButtonEventReceiver(receiver_name);
                audio_manager.abandonAudioFocus(this);
                running = false;
            } catch (Exception e) {
                // Nothing 
                e.printStackTrace();
            } 
        } 
 
        public void onAudioFocusChange(int focusChange)
        { 
            Logger.d("Audio focus" + ((focusChange>0)?"gained":"lost")+
                                         ": "+ focusChange);
            if (running)
            {   /* Play nice and stop for the the other app */ 
6
CodeRank
This code example shows how to use the following methods:unregisterMediaButtonEventReceiver
		audioManager.registerMediaButtonEventReceiver(new ComponentName(context, MediaButtonIntentReceiver.class));
	} 
 
	public static void unregisterMediaButtons(Context context) {
		AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
		audioManager.unregisterMediaButtonEventReceiver(new ComponentName(context, MediaButtonIntentReceiver.class));
	} 
 
	public static void updateWidgets(Context context) {
		AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);
 
		int[] widgetIds;
 
		widgetIds = widgetManager.getAppWidgetIds(new ComponentName(context, LargeWidgetProvider.class));
		if (widgetIds.length > 0) {
			AppWidgetProvider provider = (AppWidgetProvider) new LargeWidgetProvider();
			provider.onUpdate(context, widgetManager, widgetIds);
		} 
 
		widgetIds = widgetManager.getAppWidgetIds(new ComponentName(context, SmallWidgetProvider.class));
6
CodeRank
This code example shows how to use the following methods:abandonAudioFocus, requestAudioFocus, unregisterMediaButtonEventReceiver
        return true; 
    } 
 
    private boolean requestAudioFocus() { 
        Log.d(TAG, "Requesting audio focus.");
        return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == this.audioManager.requestAudioFocus(this,
                AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
    } 
 
    private boolean abandonAudioFocus() { 
        Log.d(TAG, "Abandoning audio focus.");
        return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == this.audioManager.abandonAudioFocus(this);
    } 
 
    public void onAudioFocusChange(int focusChange) {
        switch (focusChange) {
            case AudioManager.AUDIOFOCUS_GAIN:
                Log.d(TAG, "Re/gained focus.");
                this.startPlaybackAtFullVolume();
                break; 

5
CodeRank
This code example shows how to use the following methods:abandonAudioFocus, unregisterMediaButtonEventReceiver
            Log.d(TAG, "Releasing audio player.");
            this.mediaPlayer.release();
            this.mediaPlayer = null;
 
            Log.d(TAG, "Abandoning audio focus.");
            this.audioManager.abandonAudioFocus(this);
 
            Log.d(TAG, "Unregistering noisy audio receiver.");
            context.unregisterReceiver(this.noisyAudioReceiver);
 
            Log.d(TAG, "Unregistering remote audio control receiver.");
            this.audioManager.unregisterMediaButtonEventReceiver(this.remoteControlReceiverName);
 
            Log.d(TAG, "Stopping service.");
            this.audioPlayerService.get().stopForeground(true);
            this.audioPlayerService.get().stopSelf();
        } 
    } 
 
    public synchronized int duration() { 
4
CodeRank
This code example shows how to use the following methods:unregisterMediaButtonEventReceiver
		if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO)
			return; 
 
		AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
		ComponentName receiver = new ComponentName(context.getPackageName(), MediaButtonReceiver.class.getName());
		audioManager.unregisterMediaButtonEventReceiver(receiver);
	} 
 
	@Override 
	public void onReceive(Context context, Intent intent)
	{ 
		 
		if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
			KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
			boolean handled = processKey(context, event);
			if (handled && isOrderedBroadcast())
				abortBroadcast();
		} 
		// a bit hacky and won't work on some devices... 
		if (intent.getAction().equals("android.media.VOLUME_CHANGED_ACTION")) {
6
CodeRank
This code example shows how to use the following methods:unregisterMediaButtonEventReceiver

Related AudioManager unregisterMediaButtonEventReceiver Questions & Answers:

unregisterMediaButtonEventReceiver Method Overview
Unregister the receiver of MEDIA_BUTTON intents.
See Code Examples for other Android AudioManager Methods: