DownloadNotificationHelper


@UnstableApi
public final class DownloadNotificationHelper


Helper for creating download notifications.

Summary

Public constructors

Public methods

Notification
buildDownloadCompletedNotification(
    Context context,
    @DrawableRes int smallIcon,
    @Nullable PendingIntent contentIntent,
    @Nullable String message
)

Returns a notification for a completed download.

Notification
buildDownloadFailedNotification(
    Context context,
    @DrawableRes int smallIcon,
    @Nullable PendingIntent contentIntent,
    @Nullable String message
)

Returns a notification for a failed download.

Notification
buildProgressNotification(
    Context context,
    @DrawableRes int smallIcon,
    @Nullable PendingIntent contentIntent,
    @Nullable String message,
    List<Download> downloads,
    @Requirements.RequirementFlags int notMetRequirements
)

Returns a progress notification for the given downloads.

Public constructors

DownloadNotificationHelper

public DownloadNotificationHelper(Context context, String channelId)
Parameters
Context context

A context.

String channelId

The id of the notification channel to use.

Public methods

buildDownloadCompletedNotification

public Notification buildDownloadCompletedNotification(
    Context context,
    @DrawableRes int smallIcon,
    @Nullable PendingIntent contentIntent,
    @Nullable String message
)

Returns a notification for a completed download.

Parameters
Context context

A context.

@DrawableRes int smallIcon

A small icon for the notifications.

@Nullable PendingIntent contentIntent

An optional content intent to send when the notification is clicked.

@Nullable String message

An optional message to display on the notification.

Returns
Notification

The notification.

buildDownloadFailedNotification

public Notification buildDownloadFailedNotification(
    Context context,
    @DrawableRes int smallIcon,
    @Nullable PendingIntent contentIntent,
    @Nullable String message
)

Returns a notification for a failed download.

Parameters
Context context

A context.

@DrawableRes int smallIcon

A small icon for the notifications.

@Nullable PendingIntent contentIntent

An optional content intent to send when the notification is clicked.

@Nullable String message

An optional message to display on the notification.

Returns
Notification

The notification.

buildProgressNotification

public Notification buildProgressNotification(
    Context context,
    @DrawableRes int smallIcon,
    @Nullable PendingIntent contentIntent,
    @Nullable String message,
    List<Download> downloads,
    @Requirements.RequirementFlags int notMetRequirements
)

Returns a progress notification for the given downloads.

Parameters
Context context

A context.

@DrawableRes int smallIcon

A small icon for the notification.

@Nullable PendingIntent contentIntent

An optional content intent to send when the notification is clicked.

@Nullable String message

An optional message to display on the notification.

List<Download> downloads

The downloads.

@Requirements.RequirementFlags int notMetRequirements

Any requirements for downloads that are not currently met.

Returns
Notification

The notification.