It does not look like you can add a fragment. You could see if MediaStyle fits your needs. In your notification builder you would add .setStyle(NotificationCompat.MediaStyle)
. Otherwise it looks like you would have to subclass Notification.Style
or NotificationCompat.Style
to create a custom layout. It also looks like for some options you can intercept the notification as it's being created. Check this out for more details.
Edit:
Given your time frame, and if you're willing to flex some on your layout, then I would just add buttons to the notification. Create a pending intent for each action you want to be able to do from your notification (play, pause, skip). By way of a code sample I've included an abbreviated version of how I put a dismiss button in my notifications.
Intent resultIntent = new Intent(context, AlarmScreen.class);
resultIntent.putExtra("Id",reminder.getId());
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
context,
reminder.getId()*2,
resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT
);
Notification.Builder mBuilder =
new Notification.Builder(context)
.setStyle(new Notification.BigTextStyle()
.bigText(reminder.getDescription()))
.addAction(R.drawable.ic_stat_content_clear, "Dismiss", dismissPendingIntent)
.build();
In your case you should be able to replace the R.drawable.ic_stat_content_clear
with an appropriate icon and maybe skip the text. You can just repeat .addAction()
for each button you want. Notice also where I have reminder.getId()*2
in my pending intent declaration? I found that if I had the same number there for both of my buttons I got strange results, so one of my buttons has id*2
and the other has id*2+1
.
As for how you handle the intents sent by the buttons, you'll have to create a BroadcastReceiver
to receive them, and figure out where to go from there based on how you're implementing the rest of your logic.