0

From Android docs:

When the user selects the Now Playing card, the system opens the app that owns the session. If your app provides a PendingIntent to setSessionActivity(), the system launches the activity you specify, as demonstrated below. If not, the default system intent opens. The activity you specify must provide playback controls that allow users to pause or stop playback.

Player.class

if (mSession== null) {
            mSession= new mSession(this, ...);
            mSession.setCallback(new MediaSessionCallback());
            mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS |
                    MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);

            Context context = getApplicationContext();
            Intent i = new Intent(context, Player.class);
            PendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,
                    i, PendingIntent.FLAG_UPDATE_CURRENT);
            mSession.setSessionActivity(pi);
}

protected class MediaSessionCallback extends MediaSession.Callback {
        @Override
        public void onPlay() {
            ...
        }

        @Override
        public void onPause() {
            ...
        }

}

After clicking Now Playing card, application returns grey screen and nothing else. Maybe someone has experience with this?

MaaAn13
  • 264
  • 5
  • 24
  • 54
  • In the [documentation](https://developer.android.com/training/tv/playback/now-playing.html), be noted that the activity you specify must provide playback controls that allow users to pause or stop playback. You may check this [thread](https://stackoverflow.com/questions/20546703/how-to-fix-white-screen-on-app-start-up) which suggested to include the transparent theme to the starting activity in the AndroidManifest.xml file. – abielita Aug 02 '17 at 17:12
  • @abielita Activity provided has playback controls. Question is, why the playback state isn't saved, meanwhile, when I don't setup Now playing card (mSession.setActive(false)), then Playback state is saved (obv. now playing card disappears) – MaaAn13 Aug 07 '17 at 07:26

0 Answers0