public class DemoJobCreator implements JobCreator { @ Override public Job create( String tag) { switch (tag) { case DemoSyncJob. TAG: return new DemoSyncJob(); default: return null; } } } public class DemoSyncJob extends Job { public static final String TAG = "job_ demo_ tag"; @ Override @ NonNull protected Result onRunJob( final Params params) { if (params. isPeriodic()) { PendingIntent pendingIntent = PendingIntent. getActivity(
使用者设置是否只有任务执行的条件都满足了,系统才执行任务。在Android7.0中,Job循环执行时最小的间隔时间是15分钟,为了兼容Android7.0,Evernote库的任务循环执行的最小间隔时间也是15分钟。在Evernote提供的源码(JobRequest.java)中,可以看到如下说明。/** * The minimum interval of a periodic job. Specifying a smaller interval will result in an exception. * This limit comes from the {@code JobScheduler} starting with Android Nougat. */ public static final long MIN_ INTERVAL = TimeUnit. MINUTES. toMillis( 15);
-keep public class com. evernote. android. job. v21. PlatformJobService -keep public class com. evernote. android. job. v14. PlatformAlarmService -keep public class com. evernote. android. job. v14. PlatformAlarmReceiver -keep public class com. evernote. android. job. JobBootReceiver -keep public class com. evernote. android. job. JobRescheduleService
好了,APP开发公司本文关于“JobScheduler的替代解决方案”知识与代码分享就到这里,谢谢关注,博纳网络编辑整理。