keyboardr
keyboardr

Reputation: 851

Using MediaSessionManager.OnActiveSessionsChangedListener on AndroidTV

I'm trying to listen for changes to the active media sessions on my Android TV (specifically to set my Hue lights into a sort of "movie mode"). On a normal Android device (4.3+) I'd set up a NotificationListenerService to allow me to call MediaSessionManager.addOnActiveSessionsChangedListener().

The problem is that Android TV doesn't seem to have a UI to enable my NotificationListenerService, and there is nothing to handle Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS. Does anyone know of another approach to listen for media changes or a way to enable a NotificationListenerService on Android TV? This is just for my own use, so this doesn't need to be a scalable solution (adb is fine).

Upvotes: 3

Views: 1650

Answers (1)

j__m
j__m

Reputation: 9645

From an ADB shell:

  1. Get the current list of enabled notification listeners:

settings get secure enabled_notification_listeners

By default on my TV, this returns com.google.android.leanbacklauncher/.notifications.NotificationMonitorService.

  1. Add yours to the list, separated by a colon.

settings put secure enabled_notification_listeners com.google.android.leanbacklauncher/.notifications.NotificationMonitorService:com.example/com.example.MyNotificationListenerService

Upvotes: 2

Related Questions