library/src/main/java/com/evernote/android/job/JobManager.java
/**
     * Schedule a request which will be executed in the future. If you want to update an existing
     * {@link JobRequest}, call {@link JobRequest#cancelAndEdit()}, update your parameters and call
     * this method again. Calling this method with the same request multiple times without cancelling
     * it is idempotent.
     *
     * @param request The {@link JobRequest} which will run in the future.
     */
Schedule a request which will be executed in the future. If you want to update an existing
JobRequest, call  JobRequest#cancelAndEdit(), update your parameters and call
this method again. Calling this method with the same request multiple times without cancelling
it is idempotent.

@param request The  JobRequest which will run in the future.
Schedule a request which will be executed in the future . If you want to update an existing JobRequest call JobRequest#cancelAndEdit () update your parameters and call this method again . Calling this method with the same request multiple times without cancelling it is idempotent . @param request The JobRequest which will run in the future .
public void schedule(@NonNull JobRequest request) {
        if (mJobCreatorHolder.isEmpty()) {
            CAT.w("you haven't registered a JobCreator with addJobCreator(), it's likely that your job never will be executed");
        }
        if (request.getScheduledAt() > 0) {
            return;
        }
        if (request.isUpdateCurrent()) {
            cancelAllForTag(request.getTag());
        }
        JobProxy.Common.cleanUpOrphanedJob(mContext, request.getJobId());
        JobApi jobApi = request.getJobApi();
        boolean periodic = request.isPeriodic();
        boolean flexSupport = periodic && jobApi.isFlexSupport() && request.getFlexMs() < request.getIntervalMs();
        request.setScheduledAt(JobConfig.getClock().currentTimeMillis());
        request.setFlexSupport(flexSupport);
        mJobStorage.put(request);
        try {
            scheduleWithApi(request, jobApi, periodic, flexSupport);
            return;
        } catch (JobProxyIllegalStateException e) {
        } catch (Exception e) {
            mJobStorage.remove(request);
            throw e;
        }
        try {
            jobApi.invalidateCachedProxy();
            scheduleWithApi(request, jobApi, periodic, flexSupport);
            return;
        } catch (Exception e) {
            if (jobApi == JobApi.V_14 || jobApi == JobApi.V_19) {
                mJobStorage.remove(request);
                throw e;
            } else {
                jobApi = JobApi.V_19.isSupported(mContext) ? JobApi.V_19 : JobApi.V_14; 
            }
        }
        try {
            scheduleWithApi(request, jobApi, periodic, flexSupport);
        } catch (Exception e) {
            mJobStorage.remove(request);
            throw e;
        }
    }
public void schedule ( @ NonNull JobRequest request ) { if ( mJobCreatorHolder . isEmpty ( ) ) { CAT . w ( "you haven't registered a JobCreator with addJobCreator(), it's likely that your job never will be executed" ) ; } if ( request . getScheduledAt ( ) > 0 ) { return ; } if ( request . isUpdateCurrent ( ) ) { cancelAllForTag ( request . getTag ( ) ) ; } JobProxy . Common . cleanUpOrphanedJob ( mContext , request . getJobId ( ) ) ; JobApi jobApi = request . getJobApi ( ) ; boolean periodic = request . isPeriodic ( ) ; boolean flexSupport = periodic && jobApi . isFlexSupport ( ) && request . getFlexMs ( ) < request . getIntervalMs ( ) ; request . setScheduledAt ( JobConfig . getClock ( ) . currentTimeMillis ( ) ) ; request . setFlexSupport ( flexSupport ) ; mJobStorage . put ( request ) ; try { scheduleWithApi ( request , jobApi , periodic , flexSupport ) ; return ; } catch ( JobProxyIllegalStateException e ) { } catch ( Exception e ) { mJobStorage . remove ( request ) ; throw e ; } try { jobApi . invalidateCachedProxy ( ) ; scheduleWithApi ( request , jobApi , periodic , flexSupport ) ; return ; } catch ( Exception e ) { if ( jobApi == JobApi . V_14 || jobApi == JobApi . V_19 ) { mJobStorage . remove ( request ) ; throw e ; } else { jobApi = JobApi . V_19 . isSupported ( mContext ) ? JobApi . V_19 : JobApi . V_14 ; } } try { scheduleWithApi ( request , jobApi , periodic , flexSupport ) ; } catch ( Exception e ) { mJobStorage . remove ( request ) ; throw e ; } }
Schedule a request which will be executed in the future.
Schedule a request which will be executed in the future .
// try again below, the other cases stop // if something fails, don't keep the job in the database, it would be rescheduled later // try to reload the proxy // at this stage we cannot do anything // try one last time // if something fails, don't keep the job in the database, it would be rescheduled later