Source:
public void onReceive(Context context, Intent intent) { final long deckId = intent.getLongExtra(EXTRA_DECK_ID, 0); if (null == CollectionHelper.getInstance().getCol(context).getDecks().get(deckId, false)) { final AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); final PendingIntent reminderIntent = PendingIntent.getBroadcast( context, (int) deckId, new Intent(context, ReminderService.class).putExtra(EXTRA_DECK_ID, deckId), 0 ); alarmManager.cancel(reminderIntent); } Sched.DeckDueTreeNode deckDue = null; for (Sched.DeckDueTreeNode node : CollectionHelper.getInstance().getCol(context).getSched().deckDueTree()) { if (node.did == deckId) { deckDue = node; break; } } if (null == deckDue) { return; } final int total = deckDue.revCount + deckDue.lrnCount + deckDue.newCount; if (total <= 0) { return; } final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); if (notificationManager.areNotificationsEnabled()) { final Notification notification = new NotificationCompat.Builder(context, NotificationChannels.getId(NotificationChannels.Channel.DECK_REMINDERS)) .setCategory(NotificationCompat.CATEGORY_REMINDER) .setContentTitle(context.getString(R.string.reminder_title)) .setContentText(context.getResources().getQuantityString( R.plurals.reminder_text, total, CollectionHelper.getInstance().getCol(context).getDecks().name(deckId), total )) .setSmallIcon(R.drawable.ic_stat_notify) .setColor(ContextCompat.getColor(context, R.color.material_light_blue_700)) .setContentIntent(PendingIntent.getActivity( context, (int) deckId, new Intent(context, IntentHandler.class).putExtra(EXTRA_DECK_ID, deckId), PendingIntent.FLAG_UPDATE_CURRENT )) .setAutoCancel(true) .build(); notificationManager.notify((int) deckId, notification); } }

Target:
public void onReceive(Context context, Intent intent) { final long deckId = intent.getLongExtra(EXTRA_DECK_ID, 0); if (CollectionHelper.getInstance().getCol(context).getDecks().get(deckId, false) == null) { final AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); final PendingIntent reminderIntent = PendingIntent.getBroadcast( context, (int) deckId, new Intent(context, ReminderService.class).putExtra(EXTRA_DECK_ID, deckId), 0 ); alarmManager.cancel(reminderIntent); } Sched.DeckDueTreeNode deckDue = null; for (Sched.DeckDueTreeNode node : CollectionHelper.getInstance().getCol(context).getSched().deckDueTree()) { if (node.did == deckId) { deckDue = node; break; } } if (null == deckDue) { return; } final int total = deckDue.revCount + deckDue.lrnCount + deckDue.newCount; if (total <= 0) { return; } final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); if (notificationManager.areNotificationsEnabled()) { final Notification notification = new NotificationCompat.Builder(context, NotificationChannels.getId(NotificationChannels.Channel.DECK_REMINDERS)) .setCategory(NotificationCompat.CATEGORY_REMINDER) .setContentTitle(context.getString(R.string.reminder_title)) .setContentText(context.getResources().getQuantityString( R.plurals.reminder_text, total, CollectionHelper.getInstance().getCol(context).getDecks().name(deckId), total )) .setSmallIcon(R.drawable.ic_stat_notify) .setColor(ContextCompat.getColor(context, R.color.material_light_blue_700)) .setContentIntent(PendingIntent.getActivity( context, (int) deckId, new Intent(context, IntentHandler.class).putExtra(EXTRA_DECK_ID, deckId), PendingIntent.FLAG_UPDATE_CURRENT )) .setAutoCancel(true) .build(); notificationManager.notify((int) deckId, notification); } }