Share via


AudioManager.DispatchMediaKeyEvent(KeyEvent) Method

Definition

Sends a simulated key event for a media button.

[Android.Runtime.Register("dispatchMediaKeyEvent", "(Landroid/view/KeyEvent;)V", "GetDispatchMediaKeyEvent_Landroid_view_KeyEvent_Handler")]
public virtual void DispatchMediaKeyEvent (Android.Views.KeyEvent? keyEvent);
[<Android.Runtime.Register("dispatchMediaKeyEvent", "(Landroid/view/KeyEvent;)V", "GetDispatchMediaKeyEvent_Landroid_view_KeyEvent_Handler")>]
abstract member DispatchMediaKeyEvent : Android.Views.KeyEvent -> unit
override this.DispatchMediaKeyEvent : Android.Views.KeyEvent -> unit

Parameters

keyEvent
KeyEvent

a KeyEvent instance whose key code is one of KeyEvent#KEYCODE_MUTE, KeyEvent#KEYCODE_HEADSETHOOK, KeyEvent#KEYCODE_MEDIA_PLAY, KeyEvent#KEYCODE_MEDIA_PAUSE, KeyEvent#KEYCODE_MEDIA_PLAY_PAUSE, KeyEvent#KEYCODE_MEDIA_STOP, KeyEvent#KEYCODE_MEDIA_NEXT, KeyEvent#KEYCODE_MEDIA_PREVIOUS, KeyEvent#KEYCODE_MEDIA_REWIND, KeyEvent#KEYCODE_MEDIA_RECORD, KeyEvent#KEYCODE_MEDIA_FAST_FORWARD, KeyEvent#KEYCODE_MEDIA_CLOSE, KeyEvent#KEYCODE_MEDIA_EJECT, or KeyEvent#KEYCODE_MEDIA_AUDIO_TRACK.

Attributes

Remarks

Sends a simulated key event for a media button. To simulate a key press, you must first send a KeyEvent built with a KeyEvent#ACTION_DOWN action, then another event with the KeyEvent#ACTION_UP action.

The key event will be sent to the current media key event consumer which registered with AudioManager#registerMediaButtonEventReceiver(PendingIntent).

Java documentation for android.media.AudioManager.dispatchMediaKeyEvent(android.view.KeyEvent).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to