Sdílet prostřednictvím


RemoteController.SendMediaKeyEvent(KeyEvent) Method

Definition

Caution

deprecated

Send a simulated key event for a media button to be received by the current client.

[Android.Runtime.Register("sendMediaKeyEvent", "(Landroid/view/KeyEvent;)Z", "")]
[System.Obsolete("deprecated")]
public bool SendMediaKeyEvent (Android.Views.KeyEvent? keyEvent);
[<Android.Runtime.Register("sendMediaKeyEvent", "(Landroid/view/KeyEvent;)Z", "")>]
[<System.Obsolete("deprecated")>]
member this.SendMediaKeyEvent : Android.Views.KeyEvent -> bool

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.

Returns

true if the event was successfully sent, false otherwise.

Attributes

Exceptions

Remarks

Send a simulated key event for a media button to be received by the current client. 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 registered receiver (see AudioManager#registerMediaButtonEventReceiver(PendingIntent)) whose associated RemoteControlClient's metadata and playback state is published (there may be none under some circumstances).

Java documentation for android.media.RemoteController.sendMediaKeyEvent(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