public class BatchingScheduler extends Scheduler
This BatchingScheduler wraps a generic scheduler and avoid calling the system service if a request is made that has the same criteria as the previous one.
Scheduler.Callback| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_BATCHING_PERIOD_IN_MS |
| Constructor and Description |
|---|
BatchingScheduler(Scheduler delegate,
Timer timer)
Creates a scheduler that wraps another scheduler and batches similar jobs into a single
request to minimize IPC.
|
BatchingScheduler(Scheduler delegate,
Timer timer,
long batchingDurationInMs)
Creates a scheduler that wraps another scheduler and batches similar jobs into a single
request to minimize IPC.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancelAll()
When called, should cancel all pending jobs
|
void |
init(android.content.Context context,
Scheduler.Callback callback) |
void |
onFinished(SchedulerConstraint constraint,
boolean reschedule)
Called by the JobManager when a scheduled constraint is handled.
|
void |
request(SchedulerConstraint constraint) |
public BatchingScheduler(Scheduler delegate, Timer timer)
This constructor uses 15 minutes as the batching range.
delegate - The actual schedulertimer - The Timer instance used by the JobManagerpublic BatchingScheduler(Scheduler delegate, Timer timer, long batchingDurationInMs)
delegate - The actual schedulertimer - The Timer instance used by the JobManagerbatchingDurationInMs - Jobs whose criteria match and execution period is within this
value will be merged into 1 request.public void init(android.content.Context context,
Scheduler.Callback callback)
public void request(SchedulerConstraint constraint)
public void onFinished(SchedulerConstraint constraint, boolean reschedule)
ScheduleronFinished in class Schedulerconstraint - The original constraintreschedule - True if the job should be rescheduled