0

I have a NotificationListenerService with the appropriate permissions. On Monday morning (June 12th) everything was working fine and had been working for about a month, but then sometime mid Monday things got wonky without any code changes.

Previously I could open YouTube and as expected when I played content I would get the name of whatever is playing. Now this notification does not fire until I hit the home screen. It does not matter if I play the content for 3 seconds or 3 hours: it will not notify until I hit home. This is on an Android 11 Hisense TV, but I've also reproduced it in a generic Android 11 emulator.

Interestingly enough, I noticed that this issue only happens in the Android R Google TV emulator. The Android R Android TV emulator does not have this issue.

I'm not sure if this is a temporary bug with Google TV or intended functionality, but I can't find any answers on this issue.

This is the code I'm using to print the content:

override fun onNotificationPosted(sbn: StatusBarNotification?) {
    super.onNotificationPosted(sbn)
    if (sbn?.packageName != null) {
        val sessions = mediaSessionManager.getActiveSessions(component)
        // Dump all session information
        sessions.forEach {
            val title = it?.metadata?.getString(MediaMetadata.METADATA_KEY_TITLE)
            val state = it?.playbackState?.state
            Log.d(TAG, "$title - $state")
        }
    }
}
Goigle
  • 138
  • 13

0 Answers0