ForegroundInfo


public final class ForegroundInfo


The information required when a ListenableWorker runs in the context of a foreground service.

Summary

Public constructors

ForegroundInfo(int notificationId, @NonNull Notification notification)

Creates an instance of ForegroundInfo with a Notification.

ForegroundInfo(
    int notificationId,
    @NonNull Notification notification,
    int foregroundServiceType
)

Creates an instance of ForegroundInfo with a Notification and foreground android.app.Service type.

Public constructors

ForegroundInfo

Added in 2.3.0
public ForegroundInfo(int notificationId, @NonNull Notification notification)

Creates an instance of ForegroundInfo with a Notification.

On API 29 and above, you can specify a foregroundServiceType by using the ForegroundInfo constructor; otherwise, a default foregroundServiceType of 0 will be used.

Parameters
int notificationId

The Notification id

@NonNull Notification notification

The Notification to show when the Worker is running in the context of a foreground android.app.Service

ForegroundInfo

Added in 2.3.0
public ForegroundInfo(
    int notificationId,
    @NonNull Notification notification,
    int foregroundServiceType
)

Creates an instance of ForegroundInfo with a Notification and foreground android.app.Service type. For more information look at android.app.Service#startForeground(int, Notification, int).

Parameters
int notificationId

The Notification id

@NonNull Notification notification

The Notification

int foregroundServiceType

The foreground android.content.pm.ServiceInfo type

Public methods

equals

public boolean equals(Object o)

getForegroundServiceType

Added in 2.3.0
public int getForegroundServiceType()
Returns
int

The foreground android.content.pm.ServiceInfo type

getNotification

Added in 2.3.0
public @NonNull Notification getNotification()
Returns
@NonNull Notification

The user visible Notification

getNotificationId

Added in 2.3.0
public int getNotificationId()
Returns
int

The Notification id to be used

hashCode

public int hashCode()

toString

public String toString()