public class

CombineContinuationsWorker

extends Worker

 java.lang.Object

androidx.work.ListenableWorker

androidx.work.Worker

↳androidx.work.impl.workers.CombineContinuationsWorker

Gradle dependencies

compile group: 'androidx.work', name: 'work-runtime', version: '2.8.0-alpha02'

  • groupId: androidx.work
  • artifactId: work-runtime
  • version: 2.8.0-alpha02

Artifact androidx.work:work-runtime:2.8.0-alpha02 it located at Google repository (https://maven.google.com/)

Overview

A Worker that helps combine work continuations.

Summary

Constructors
publicCombineContinuationsWorker(Context context, WorkerParameters workerParams)

Methods
public abstract ListenableWorker.ResultdoWork()

Override this method to do your actual background processing.

from WorkergetForegroundInfo, getForegroundInfoAsync, startWork
from ListenableWorkergetApplicationContext, getBackgroundExecutor, getId, getInputData, getNetwork, getRunAttemptCount, getTags, getTaskExecutor, getTriggeredContentAuthorities, getTriggeredContentUris, getWorkerFactory, isStopped, isUsed, onStopped, setForegroundAsync, setProgressAsync, setUsed, stop
from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public CombineContinuationsWorker(Context context, WorkerParameters workerParams)

Methods

public abstract ListenableWorker.Result doWork()

Override this method to do your actual background processing. This method is called on a background thread - you are required to synchronously do your work and return the ListenableWorker.Result from this method. Once you return from this method, the Worker is considered to have finished what its doing and will be destroyed. If you need to do your work asynchronously on a thread of your own choice, see ListenableWorker.

A Worker has a well defined execution window to finish its execution and return a ListenableWorker.Result. After this time has expired, the Worker will be signalled to stop.

Returns:

The ListenableWorker.Result of the computation; note that dependent work will not execute if you use ListenableWorker.Result.failure() or ListenableWorker.Result.failure(Data)

Source

/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.work.impl.workers;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.work.Worker;
import androidx.work.WorkerParameters;

/**
 * A {@link Worker} that helps combine work continuations.
 *
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class CombineContinuationsWorker extends Worker {

    public CombineContinuationsWorker(@NonNull Context context,
            @NonNull WorkerParameters workerParams) {
        super(context, workerParams);
    }

    @Override
    public @NonNull Result doWork() {
        return Result.success(getInputData());
    }
}