Added in API level 26

JobServiceEngine

abstract class JobServiceEngine
kotlin.Any
   ↳ android.app.job.JobServiceEngine

Helper for implementing a android.app.Service that interacts with JobScheduler. This is not intended for use by regular applications, but allows frameworks built on top of the platform to create their own android.app.Service that interact with JobScheduler as well as add in additional functionality. If you just want to execute jobs normally, you should instead be looking at JobService.

Summary

Public constructors

Create a new engine, ready for use.

Public methods
IBinder!

Retrieve the engine's IPC interface that should be returned by Service#onBind(Intent).

open Unit
jobFinished(params: JobParameters!, needsReschedule: Boolean)

Call in to engine to report that a job has finished executing.

open Unit

Engine's report that the network for the job has changed.

abstract Boolean

Engine's report that a job has started.

abstract Boolean

Engine's report that a job has stopped.

open Unit
setNotification(params: JobParameters, notificationId: Int, notification: Notification, jobEndNotificationPolicy: Int)

Give JobScheduler a notification to tie to this job's lifecycle.

open Unit
updateEstimatedNetworkBytes(params: JobParameters, item: JobWorkItem?, downloadBytes: Long, uploadBytes: Long)

Call in to engine to report data transfer progress.

open Unit
updateTransferredNetworkBytes(params: JobParameters, item: JobWorkItem?, downloadBytes: Long, uploadBytes: Long)

Call in to engine to report data transfer progress.

Public constructors

JobServiceEngine

Added in API level 26
JobServiceEngine(service: Service!)

Create a new engine, ready for use.

Parameters
service Service!: The Service that is creating this engine and in which it will run.

Public methods

getBinder

Added in API level 26
fun getBinder(): IBinder!

Retrieve the engine's IPC interface that should be returned by Service#onBind(Intent).

jobFinished

Added in API level 26
open fun jobFinished(
    params: JobParameters!,
    needsReschedule: Boolean
): Unit

Call in to engine to report that a job has finished executing. See JobService#jobFinished(JobParameters, boolean) for more information.

onNetworkChanged

Added in API level 34
open fun onNetworkChanged(params: JobParameters): Unit

Engine's report that the network for the job has changed.

Parameters
params JobParameters: This value cannot be null.

onStartJob

Added in API level 26
abstract fun onStartJob(params: JobParameters!): Boolean

Engine's report that a job has started. See JobService.onStartJob for more information.

onStopJob

Added in API level 26
abstract fun onStopJob(params: JobParameters!): Boolean

Engine's report that a job has stopped. See JobService.onStopJob for more information.

setNotification

Added in API level 34
open fun setNotification(
    params: JobParameters,
    notificationId: Int,
    notification: Notification,
    jobEndNotificationPolicy: Int
): Unit

Give JobScheduler a notification to tie to this job's lifecycle.

Parameters
params JobParameters: This value cannot be null.
notification Notification: This value cannot be null.
jobEndNotificationPolicy Int: Value is android.app.job.JobService#JOB_END_NOTIFICATION_POLICY_DETACH, or android.app.job.JobService#JOB_END_NOTIFICATION_POLICY_REMOVE

updateEstimatedNetworkBytes

Added in API level 34
open fun updateEstimatedNetworkBytes(
    params: JobParameters,
    item: JobWorkItem?,
    downloadBytes: Long,
    uploadBytes: Long
): Unit

Call in to engine to report data transfer progress.

Parameters
params JobParameters: This value cannot be null.
item JobWorkItem?: This value may be null.
downloadBytes Long: Value is a non-negative number of bytes.
uploadBytes Long: Value is a non-negative number of bytes.

updateTransferredNetworkBytes

Added in API level 34
open fun updateTransferredNetworkBytes(
    params: JobParameters,
    item: JobWorkItem?,
    downloadBytes: Long,
    uploadBytes: Long
): Unit

Call in to engine to report data transfer progress.

Parameters
params JobParameters: This value cannot be null.
item JobWorkItem?: This value may be null.
downloadBytes Long: Value is a non-negative number of bytes.
uploadBytes Long: Value is a non-negative number of bytes.