/** * Returns a notification for a completed download. * * @param context A context for accessing resources. * @param smallIcon A small icon for the notifications. * @param channelId The id of the notification channel to use. Only required for API level 26 and * above. * @param contentIntent An optional content intent to send when the notification is clicked. * @param message An optional message to display on the notification. * @return The notification. */ public static Notification buildDownloadCompletedNotification( Context context, @DrawableRes int smallIcon, String channelId, @Nullable PendingIntent contentIntent, @Nullable String message) { int titleStringId = R.string.exo_download_completed; return newNotificationBuilder( context, smallIcon, channelId, contentIntent, message, titleStringId) .build(); }
DownloadNotificationUtil.buildDownloadCompletedNotification( /* context= */ this, R.drawable.exo_controls_play, DownloadNotificationUtil.buildDownloadFailedNotification( /* context= */ this, R.drawable.exo_controls_play,
@Override protected Notification getForegroundNotification(TaskState[] taskStates) { return DownloadNotificationUtil.buildProgressNotification( /* context= */ this, R.drawable.exo_controls_play, CHANNEL_ID, /* contentIntent= */ null, /* message= */ null, taskStates); }
/** * Returns a notification for a failed download. * * @param context A context for accessing resources. * @param smallIcon A small icon for the notifications. * @param channelId The id of the notification channel to use. Only required for API level 26 and * above. * @param contentIntent An optional content intent to send when the notification is clicked. * @param message An optional message to display on the notification. * @return The notification. */ public static Notification buildDownloadFailedNotification( Context context, @DrawableRes int smallIcon, String channelId, @Nullable PendingIntent contentIntent, @Nullable String message) { @StringRes int titleStringId = R.string.exo_download_failed; return newNotificationBuilder( context, smallIcon, channelId, contentIntent, message, titleStringId) .build(); }
: (haveRemoveTasks ? R.string.exo_download_removing : NULL_STRING_ID); NotificationCompat.Builder notificationBuilder = newNotificationBuilder( context, smallIcon, channelId, contentIntent, message, titleStringId);