AudioManager registerMediaButtonEventReceiver - 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 registerMediaButtonEventReceiver method.

This code example shows how to use the following methods:registerMediaButtonEventReceiver, requestAudioFocus
        } 
         
        public void register() 
        { 
            try { 
                audio_manager.registerMediaButtonEventReceiver(receiver_name);
                audio_manager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
                running = true;
            } catch (Exception e) {
                // Nothing 
                e.printStackTrace();
            } 
        } 
 
        public void unregister() 
        { 
            try 
            { 
                audio_manager.unregisterMediaButtonEventReceiver(receiver_name);
                audio_manager.abandonAudioFocus(this);
6
CodeRank
This code example shows how to use the following methods:registerMediaButtonEventReceiver
	/** 
	 * Calls {@link AudioManager#registerMediaButtonEventReceiver(ComponentName)}. 
	 */ 
	public static void registerMediaButtonEventReceiver(AudioManager manager, ComponentName receiver)
	{ 
		manager.registerMediaButtonEventReceiver(receiver);
	} 
 
	/** 
	 * 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)
6
CodeRank
This code example shows how to use the following methods:registerMediaButtonEventReceiver, requestAudioFocus
				.getSystemService(Context.AUDIO_SERVICE);
	} 
 
	@Override 
	public void onPlaybackStarted() { 
		mAudioService.requestAudioFocus(mAudioFocusChangeListener,
				AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
		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);
6
CodeRank
This code example shows how to use the following methods:registerMediaButtonEventReceiver
		return false; 
	} 
 
	public static void registerMediaButtons(Context context) {
		AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
		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) {
5
CodeRank
This code example shows how to use the following methods:registerMediaButtonEventReceiver, registerRemoteControlClient
5
CodeRank
This code example shows how to use the following methods:registerMediaButtonEventReceiver
		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.registerMediaButtonEventReceiver(receiver);
	} 
 
	/** 
	 * Unregister the media buttons from AudioManager. 
	 * 
	 * @param context A context to use. 
	 */ 
	public static void unregisterMediaButton(Context context)
	{ 
		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());
4
CodeRank
This code example shows how to use the following methods:registerMediaButtonEventReceiver
        registerButtons(); 
    } 
     
    public void registerButtons() 
    { 
        am.registerMediaButtonEventReceiver(new ComponentName(c.getPackageName(), RemoteControlReceiver.class.getName()));
    } 
     
    public void setCallback(MediaButtonsHandlerInterface call)
    { 
        cb = call;
    } 
     
    public class RemoteControlReceiver extends BroadcastReceiver
    { 
        public RemoteControlReceiver() 
        { 
            super(); 
        } 
        @Override 
4
CodeRank
This code example shows how to use the following methods:registerMediaButtonEventReceiver
This code example shows how to use the following methods:registerMediaButtonEventReceiver
This code example shows how to use the following methods:registerMediaButtonEventReceiver
    ComponentName componentName;
 
    @Override 
    public void onReceive(Context context, Intent intent) {
        WizdroidApplication.getInjector().injectMembers(this);
        audioManager.registerMediaButtonEventReceiver(componentName);
    } 
} 
4
CodeRank

Related AudioManager registerMediaButtonEventReceiver Questions & Answers:

registerMediaButtonEventReceiver Method Overview
Register a component to be the sole receiver of MEDIA_BUTTON intents.
See Code Examples for other Android AudioManager Methods: