我已经在我的 android 应用程序中实现了 Evernote Android Job
implementation 'com.evernote:android-job:1.2.6'
我已经定义为signleton来获取实例我已经在我的Application类中通过
JobManager.create(this).addJobCreator(new CreatingJob());
我有两个课程是 创造就业课程
public class CreatingJob implements JobCreator {
@Nullable
@Override
public Job create(@NonNull String tag) {
switch (tag) {
case SyncMasterDataJOB.TAG:
return new SyncMasterDataJOB();
}
return null;
}
}
工作类别
public class SyncMasterDataJOB extends Job {
public static final String TAG = "job_note_sync";
@NonNull
@Override
protected Result onRunJob(@NonNull Params params) {
//Doing my Task HERE
MyLog.ShowELog("JOB STARTED", "Job Has been Started");
MyToast.Lmsg(getContext(), "Job Has been Started");
return Result.SUCCESS;
}
public static void scheduleJob() {
Set<JobRequest> jobRequests = JobManager.instance().getAllJobRequestsForTag(SyncMasterDataJOB.TAG);
if (!jobRequests.isEmpty()) {
return;
}
new JobRequest.Builder(SyncMasterDataJOB.TAG)
.setPeriodic(MIN_INTERVAL, MIN_FLEX)
.build()
.schedule();
}
}
但问题是我的 onRunJob() 方法从未被调用过。我是 Android JOBS 的新手。谁能告诉我我在哪里做错了?
我从这里参考