Google 致力于为黑人社区推动种族平等。查看具体举措

ForegroundInfo

public final class ForegroundInfo
extends Object

java.lang.Object
   ↳ androidx.work.ForegroundInfo


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

Summary

Public constructors

ForegroundInfo(int notificationId, Notification notification)

Creates an instance of ForegroundInfo with a Notification.

ForegroundInfo(int notificationId, Notification notification, int foregroundServiceType)

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

Public methods

boolean equals(Object o)
int getForegroundServiceType()
Notification getNotification()
int getNotificationId()
int hashCode()
String toString()

Inherited methods

Public constructors

ForegroundInfo

public ForegroundInfo (int notificationId, 
                Notification notification)

Creates an instance of ForegroundInfo with a Notification.

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

Parameters
notificationId int: The Notification id

notification Notification: The Notification to show when the Worker is running in the context of a foreground Service

ForegroundInfo

public ForegroundInfo (int notificationId, 
                Notification notification, 
                int foregroundServiceType)

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

Parameters
notificationId int: The Notification id

notification Notification: The Notification

foregroundServiceType int: The foreground ServiceInfo type

Public methods

equals

public boolean equals (Object o)

Parameters
o Object

Returns
boolean

getForegroundServiceType

public int getForegroundServiceType ()

Returns
int The foreground ServiceInfo type

getNotification

public Notification getNotification ()

Returns
Notification The user visible Notification

getNotificationId

public int getNotificationId ()

Returns
int The Notification id to be used

hashCode

public int hashCode ()

Returns
int

toString

public String toString ()

Returns
String