public Builder cancelAndEdit ( ) { // create a temporary variable, because .cancel() will reset mScheduledAt long scheduledAt = mScheduledAt ; JobManager . instance ( ) . cancel ( getJobId ( ) ) ; Builder builder = new Builder ( this . mBuilder ) ; mStarted = false ; if ( ! isPeriodic ( ) ) { long offset = JobConfig . getClock ( ) . currentTimeMillis ( ) - scheduledAt ; long minValue = 1L ; // 1ms builder . setExecutionWindow ( Math . max ( minValue , getStartMs ( ) - offset ) , Math . max ( minValue , getEndMs ( ) - offset ) ) ; } return builder ; }
Cancel this request if it has been scheduled . Note that if the job isn t periodic then the time passed since the job has been scheduled is subtracted from the time frame . For example a job should run between 4 and 6 seconds from now . You cancel the scheduled job after 2 seconds then the job will run between 2 and 4 seconds after it s been scheduled again .