Language

MediaSessionManager.GetActiveSessionsForPackage Method

Definition

Overloads

Name Description
GetActiveSessionsForPackage(String)

Get a list of MediaSession.Token for all active sessions for the packageName.

GetActiveSessionsForPackage(String, ComponentName)

Get a list of MediaSession.Token for all active sessions for the packageName.

GetActiveSessionsForPackage(String)

Get a list of MediaSession.Token for all active sessions for the packageName.

[Android.Runtime.Register("getActiveSessionsForPackage", "(Ljava/lang/String;)Ljava/util/List;", "", ApiSince=37)]
[Android.Runtime.RequiresPermission("android.permission.MEDIA_CONTENT_CONTROL")]
public System.Collections.Generic.IList<Android.Media.Session.MediaSession.Token> GetActiveSessionsForPackage(string packageName);
[<Android.Runtime.Register("getActiveSessionsForPackage", "(Ljava/lang/String;)Ljava/util/List;", "", ApiSince=37)>]
[<Android.Runtime.RequiresPermission("android.permission.MEDIA_CONTENT_CONTROL")>]
member this.GetActiveSessionsForPackage : string -> System.Collections.Generic.IList<Android.Media.Session.MediaSession.Token>

Parameters

packageName
String

Package name of the application for which tokens should be fetched.

Returns

A list of MediaSession.Token for active sessions of the calling application.

Attributes

Remarks

Get a list of MediaSession.Token for all active sessions for the packageName. The tokens will be provided in priority order with the most important controller at index 0.

If the packageName is provided and is different from Context.getPackageName(), this requires the Manifest.permission.MEDIA_CONTENT_CONTROL permission be held by the calling app.

Android reference for android.media.session.MediaSessionManager.getActiveSessionsForPackage.

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

GetActiveSessionsForPackage(String, ComponentName)

Get a list of MediaSession.Token for all active sessions for the packageName.

[Android.Runtime.Register("getActiveSessionsForPackage", "(Ljava/lang/String;Landroid/content/ComponentName;)Ljava/util/List;", "", ApiSince=37)]
[Android.Runtime.RequiresPermission("android.permission.MEDIA_CONTENT_CONTROL")]
public System.Collections.Generic.IList<Android.Media.Session.MediaSession.Token> GetActiveSessionsForPackage(string packageName, Android.Content.ComponentName? notificationListener);
[<Android.Runtime.Register("getActiveSessionsForPackage", "(Ljava/lang/String;Landroid/content/ComponentName;)Ljava/util/List;", "", ApiSince=37)>]
[<Android.Runtime.RequiresPermission("android.permission.MEDIA_CONTENT_CONTROL")>]
member this.GetActiveSessionsForPackage : string * Android.Content.ComponentName -> System.Collections.Generic.IList<Android.Media.Session.MediaSession.Token>

Parameters

packageName
String

Package name of the application for which tokens should be fetched.

notificationListener
ComponentName

The enabled notification listener component. May be null.

Returns

A list of controllers for active sessions of the calling application.

Attributes

Remarks

Get a list of MediaSession.Token for all active sessions for the packageName. The tokens will be provided in priority order with the most important controller at index 0.

If the packageName is provided and is different from Context.getPackageName(), this requires the Manifest.permission.MEDIA_CONTENT_CONTROL permission be held by the calling app. You may also retrieve this list if your app is an enabled notification listener using the NotificationListenerService APIs, in which case you must pass the ComponentName of your enabled listener. If none of them applies, it will throw a SecurityException.

Android reference for android.media.session.MediaSessionManager.getActiveSessionsForPackage.

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