0

I'm making my radio-app available for Android TV.

All issues solved but my app is still rejected:

No Now Playing notification [card]" Your App does not contain a “Now Playing” notification [card] for when the user has selected the HOME button within the app. Please refer to our Displaying a Now Playing Card documentation for more details.

In test everything works oke. The Now Playing Card is shown when the user presses Home in the app. And when selecting the Now Playing Card the app is opened again. I've no clue what's going wrong here. Has anyone experience the same problem? And how was is resolved? It's impossible to get in to contact met Google to clear up what's going wrong.

I use the code as explained by Google:

val intent = Intent(applicationContext, NowPlaying::class.java)
val pendingIntent =  PendingIntent.getActivity(this, 99, intent, PendingIntent.FLAG_IMMUTABLE)

mediaSessionCompat!!.setSessionActivity(pendingIntent)

I found two questions about the same but no answer was provided.

The Now Playing Card is shown on the screensaver:

enter image description here And in the Home Screen:

enter image description here

Update: I did some testing ... pressing the Now Play Card works on Google TV API31 and on Chromecast with Google TV API31.

But not on Android TV API31. When pressing "open" nothing happens.

enter image description here

Anyone an idea to get the "open" button working?

This is the code specific for TV:

if (mDevice == Device.TV) {

        //GoogleTV API31 werkt klik op nowplayingcard
        //AndroidTV API31 werkt klik NIET op nowplayingcard
        //Chromecast With Google TV werkt klik op nowplayingcard

        //click op stop in AndroidTV roep onPause() aan

        val intent = Intent(applicationContext, NowPlaying::class.java)
        val pendingIntent =  PendingIntent.getActivity(this, 99, intent, PendingIntent.FLAG_IMMUTABLE)

        mediaSessionCompat!!.setSessionActivity(pendingIntent)

    }

If I remove that code my app is opened but not the NowPlaying page as should be.

  • Did you found the solution?. I'm facing same issue. In some Android TV ( till Android 11) open button working fine but in some Android TV (Above Android 11) not working. Seems like system refusing to launch activity from background. – Azay Gupta Dec 11 '22 at 07:04
  • No. Android TV API31 triggers onPause when you press stop. It doesn't trigger the Intent somehow. I can't figure out how the open button can be triggert?! – Patrick Koning Dec 12 '22 at 09:27
  • I got the issue, Use activity context not application context for OPEN button. PendingIntent.getActivity( activityContext, 0, launchIntentForPackage, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) – Azay Gupta Dec 12 '22 at 10:35
  • Doesn’t work for me. My mediaplayer is running as a seperate service. Any idea how to deal with that? – Patrick Koning Feb 07 '23 at 08:46
  • Don't provide any pending intent for Tv, because TV app uses own widget based on MediaSession. It's working for me now. – Azay Gupta Feb 08 '23 at 12:20
  • When I remove the pending intent my app opens, but not on the NowPlaying page as it should by Google rules. I understand that you therefore have to provide a pending intent. – Patrick Koning Feb 09 '23 at 08:56
  • Can we get in contact via mail? Info@radioned.nl – Patrick Koning Feb 13 '23 at 20:08

2 Answers2

0

Use activityContext for pending intent.

PendingIntent.getActivity( activityContext, 0, launchIntentForPackage, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE )

Azay Gupta
  • 281
  • 2
  • 16
0

Somehow my approach was good. Google accepted my app for Google/Android TV (probably after an update for Google/Android TV. Ik looks like that not opening my app on Android TV was a Android bug somehow.