Closed kpradeepkumarreddy closed 6 years ago
You can create a Single Instance Job using singleInstanceBy(String instanceId)
. have a look at Single Instance Jobs section.
Note: You need second job to replace older job. but library will cancel second job if there is a job in queue with same instanceId, instead of replacing it.
I'm using the following piece of code to ensure that a job is not running with same id. Is this the correct way to do it ?
JobStatus jobStatus = Jobmanager.getJobStatus("ID");
if (jobStatus.ordinal() == JobStatus.UNKNOWN.ordinal()) {
Jobmanager.addJob(new Job());
}
Yeah, this approach also works. Only thing to note is that you have to run this code on non main thread, other wise it may cause UI jank.
Thanks.
what happens if a job with same Id already exists ? I want to have only job with the same Id. when i try to add a new job with same Id then the old job should be replaced with new one .
How can i create a job with unique Id ? Is there anything like setUnique(true) for a job ?