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?