Share via


MediaSession.SetMediaButtonBroadcastReceiver(ComponentName) Method

Definition

Set the component name of the manifest-declared android.content.BroadcastReceiver class that should receive media buttons.

[Android.Runtime.Register("setMediaButtonBroadcastReceiver", "(Landroid/content/ComponentName;)V", "", ApiSince=31)]
public void SetMediaButtonBroadcastReceiver (Android.Content.ComponentName? broadcastReceiver);
[<Android.Runtime.Register("setMediaButtonBroadcastReceiver", "(Landroid/content/ComponentName;)V", "", ApiSince=31)>]
member this.SetMediaButtonBroadcastReceiver : Android.Content.ComponentName -> unit

Parameters

broadcastReceiver
ComponentName

the component name of the BroadcastReceiver class

Attributes

Remarks

Set the component name of the manifest-declared android.content.BroadcastReceiver class that should receive media buttons. This allows restarting playback after the session has been stopped. If your app is started in this way an Intent#ACTION_MEDIA_BUTTON intent will be sent to the broadcast receiver. On apps targeting Android U and above, this will throw an IllegalArgumentException if the provided ComponentName does not resolve to an existing android.content.BroadcastReceiver broadcast receiver.

Note: The given android.content.BroadcastReceiver should belong to the same package as the context that was given when creating MediaSession.

Java documentation for android.media.session.MediaSession.setMediaButtonBroadcastReceiver(android.content.ComponentName).

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