2016-10-09 5 views
2

되풀이 작업을 만들었으므로 일부 조건이 충족되면 되풀이 작업을 취소하고 싶습니다.firebase 작업 디스패처에서 되풀이 작업을 취소하는 방법

final Job.Builder builder = dispatcher.newJobBuilder() 
       .setTag("myJob") 
       .setService(myJobService.class) 
       .setRecurring(true) 
       .setTrigger(Trigger.executionWindow(30, 60)); 

어떻게하면 firebase에서 작업을 취소 할 수 있습니까?

답변

4

GitHub의에 대한 추가 정보는 말한다 :

드라이버 예약, 취소, 작업을 실행할 수있는 구성 요소를 나타내는 인터페이스입니다. 번들로 제공되는 유일한 드라이버는 Google Play 서비스에 내장 된 스케줄러를 사용하는 GooglePlayDriver입니다.

그래서 취소는 사용중인 드라이버의 일부입니다. 당신이 전화를해야 귀하의 경우 그래서

/** 
* Cancels the job with the provided tag and class. 
* 
* @return one of the CANCEL_RESULT_ constants. 
*/ 
@CancelResult 
int cancel(@NonNull String tag); 

/** 
* Cancels all jobs registered with this Driver. 
* 
* @return one of the CANCEL_RESULT_ constants. 
*/ 
@CancelResult 
int cancelAll(); 

: 작업 취소 할 수있는 두 가지 방법이 있습니다 the code of the driver interface 검사

dispatcher.cancel("myJob"); 

또는

dispatcher.cancelAll(); 

하면 발송자의 해당 메소드를 호출 당신을위한 운전사. 당신은 또한 당신의 드라이버 myDriver.cancelAll()like it is done in the sample app which comes with the GitHub project.

에서 직접 메소드를 호출 할 수 원하는 경우 다음 상수 중 하나를 반환합니다 선택된 방법 :

public static final int CANCEL_RESULT_SUCCESS = 0; 
public static final int CANCEL_RESULT_UNKNOWN_ERROR = 1; 
public static final int CANCEL_RESULT_NO_DRIVER_AVAILABLE = 2; 
+0

이 언급 모든 문서가 있습니까? – John

+0

아니, 근원에서 찾았습니다. 나는 대답을 조금 더 구체화했다. – Henning

+0

readme는 editet이며 지금 설명합니다. – Henning