Android Open Source - JobSchedulerCompat Job Scheduler






From Project

Back to project page JobSchedulerCompat.

License

The source code is released under:

Apache License

If you think the Android project JobSchedulerCompat listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package me.tatarka.support.job;
/* w  w  w.  j  a  v  a  2  s  .c om*/
import android.content.Context;
import android.os.Build;

import java.util.List;

import me.tatarka.support.internal.JobSchedulerCompat;
import me.tatarka.support.internal.JobSchedulerLollipopDelegate;

/**
 * Created by evantatarka on 10/21/14.
 */
public abstract class JobScheduler {
    /**
     * Returned from {@link #schedule(JobInfo)} when an invalid parameter was supplied. This can
     * occur if the run-time for your job is too short, or perhaps the system can't resolve the
     * requisite {@link JobService} in your package.
     */
    public static final int RESULT_FAILURE = 0;

    /**
     * Returned from {@link #schedule(JobInfo)} if this application has made too many requests for
     * work over too short a time.
     */
    // TODO: Determine if this is necessary.
    public static final int RESULT_SUCCESS = 1;

    /**
     * @param job The job you wish scheduled. See {@link JobInfo.Builder JobInfo.Builder} for more
     *            detail on the sorts of jobs you can schedule.
     * @return If >0, this int returns the jobId of the successfully scheduled job. Otherwise you
     * have to compare the return value to the error codes defined in this class.
     */
    public abstract int schedule(JobInfo job);

    /**
     * Cancel a job that is pending in the JobScheduler.
     *
     * @param jobId unique identifier for this job. Obtain this value from the jobs returned by
     *              {@link #getAllPendingJobs()}.
     */
    public abstract void cancel(int jobId);

    /**
     * Cancel all jobs that have been registered with the JobScheduler by this package.
     */
    public abstract void cancelAll();

    /**
     * @return a list of all the jobs registered by this package that have not yet been executed.
     */
    public abstract List<JobInfo> getAllPendingJobs();

    /**
     * Get an instance of a the {@link JobScheduler}, which will delegate to the android one in api
     * 21+ and use a backported version on older apis.
     *
     * @param context the context
     * @return a JobScheduler instance
     */
    public static JobScheduler getInstance(Context context) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            return JobSchedulerLollipopDelegate.getLollipopInstance(context);
        } else {
            return JobSchedulerCompat.getCompatInstance(context);
        }
    }
}




Java Source Code List

me.tatarka.support.internal.IJobServiceCompat.java
me.tatarka.support.internal.IoThread.java
me.tatarka.support.internal.JobSchedulerCompat.java
me.tatarka.support.internal.JobSchedulerLollipopDelegate.java
me.tatarka.support.internal.job.JobSchedulerService.java
me.tatarka.support.internal.job.JobServiceCompat.java
me.tatarka.support.internal.job.JobStore.java
me.tatarka.support.internal.receivers.BootReceiver.java
me.tatarka.support.internal.receivers.ControllerPrefs.java
me.tatarka.support.internal.receivers.IdleReceiver.java
me.tatarka.support.internal.receivers.JobStatus.java
me.tatarka.support.internal.receivers.NetworkReceiver.java
me.tatarka.support.internal.receivers.PowerReceiver.java
me.tatarka.support.internal.receivers.ReceiverUtils.java
me.tatarka.support.internal.receivers.TimeReceiver.java
me.tatarka.support.internal.util.ArraySet.java
me.tatarka.support.internal.util.ContainerHelpers.java
me.tatarka.support.internal.util.EmptyArray.java
me.tatarka.support.internal.util.FastXmlSerializer.java
me.tatarka.support.internal.util.MapCollections.java
me.tatarka.support.internal.util.XmlUtils.java
me.tatarka.support.job.ApplicationTest.java
me.tatarka.support.job.JobInfo.java
me.tatarka.support.job.JobParameters.java
me.tatarka.support.job.JobScheduler.java
me.tatarka.support.job.JobService.java
me.tatarka.support.job.sample.MainActivity.java
me.tatarka.support.job.sample.service.TestJobService.java
me.tatarka.support.os.PersistableBundleCompat.java
me.tatarka.support.os.PersistableBundle.java