android-jobscheduler

Clarification of setUpdateCurrent on OneOffTask

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 01:53:30
问题 I'm trying to wrap my head around the behaviour of setTag and setUpdateCurrent of OneoffTask in the GcmNetworkManager tooling. The documentation of setUpdateCurrent says this: Optional setter to specify whether this task should override any preexisting tasks with the same tag. This defaults to false, which means that a new task will not override an existing one. Fair enough, but it doesn't say what will happen to a task, it only says one thing that will not happen - i.e. the task will not

SyncAdapter vs JobScheduler

末鹿安然 提交于 2019-12-05 00:40:55
Excluding the fact that JobScheduler only supports API > 21 - are JobSchedulers designed to fully replace SyncAdapters ? Or does SyncAdapter contain any functionality lacking by JobScheduler ? My use case is syncing an RSS feed every couple of hours. This is doable with a JobScheduler - right? I would say JobScheduler is not a direct substitution for SyncAdapter , which has a much more specialized purpose (transferring data between the device and a server). JobScheduler , on the other hand, serves to schedule tasks to be executed at some point of time in future - just like AlarmManager - but

JobScheduler: controlling delay from constraints being met to job being run

≯℡__Kan透↙ 提交于 2019-12-05 00:06:41
I'm using JobScheduler to schedule jobs. Mainly I'm using it for the .setRequiredNetworkType() method, which allows you to specify that you only want the job to be scheduled when a network connection (or more specifically an unmetered connection) is established. I'm using the following pretty straightforward code to schedule my jobs: PersistableBundle extras = new PersistableBundle(); extras.putInt("anExtraInt", someInt); int networkConstraint = useUnmetered ? JobInfo.NETWORK_TYPE_UNMETERED : JobInfo.NETWORK_TYPE_ANY; ComponentName componentName = new ComponentName(context, MyJobService.class)

Android Job Scheduler - Schedule Job to execute immediately and exactly once

狂风中的少年 提交于 2019-12-04 17:20:57
问题 I am trying to use android job scheduler to schedule a job to execute immediately and exactly once. JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE); jobScheduler.cancel(1); PersistableBundle bundle = new PersistableBundle(); bundle.putInt(JobFlags.KEY_PERIODIC_SYNC_JOB, JobFlags.JOB_TYPE_INITIAL_FETCH); jobScheduler.schedule(new JobInfo.Builder(1, new ComponentName(context, SyncJobLollipop.class)) .setRequiredNetworkType(JobInfo.NETWORK_TYPE

Android JobScheduler - can't create a persistent job

﹥>﹥吖頭↗ 提交于 2019-12-04 17:09:56
问题 I am trying out the new JoScheduler API that has come with Android Lollipop. I have so far managed to successfully create and have a job run with a delay of 6000 milliseconds with no network requirements without an issue. However, I have just tried to persist the same job via using the setPersisted(true) function. As soon as the job build() function is called it now fails saying that I need the RECEIVED_BOOT_COMPLETED permission in the Manifest file. But I have added the permission: <?xml

Android java.lang.IllegalArgumentException: No such service ComponentInfo JobScheduler

十年热恋 提交于 2019-12-04 10:03:21
问题 I tried to create a simple JobScheduler job just to see how it works. but I keep getting this exception on runtime, I can't figure it out as I followed the guides step by step. This is my call: ComponentName componentName = new ComponentName(getApplicationContext(), TestService.class); JobInfo jobInfo = new JobInfo.Builder(1, componentName).setPeriodic(300000) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY).build(); JobScheduler tm = (JobScheduler) getApplicationContext().getSystemService

JobScheduler - How do I determine a unique Job ID?

不问归期 提交于 2019-12-04 10:01:32
问题 According to the documentation, jobs must have a unique Job ID per uid. If I use a 3rd party library which also schedules jobs, does this mean I can't use the same Job ID as theirs? If so, how can I avoid these kind of collisions? 回答1: If I use a 3rd party library which also schedules jobs, does this mean I can't use the same Job ID as theirs? Correct. If so, how can I avoid these kind of collisions? Ask the developer of the library what job IDs they use, or if those job IDs are configurable

Periodic JobScheduler doesn't respect constraints

戏子无情 提交于 2019-12-04 04:21:30
问题 Using the JobScheduler, I set up a simple JobService as follows: @TargetApi(21) public class SimpleJobService extends JobService { private static final String TAG = "SimpleJobService"; @Override public boolean onStartJob(JobParameters jobParameters) { if (jobParameters.isOverrideDeadlineExpired()) { Log.d(TAG, "This shouldn't happen"); Toast.makeText(this, "This shouldn't happen", Toast.LENGTH_LONG).show(); } jobFinished(jobParameters, false); return true; } @Override public boolean onStopJob

Android O: can we make a clock widget?

▼魔方 西西 提交于 2019-12-04 02:57:38
There is a clock widget in our app. The widget needs to be updated every minute to display the time right. In Android O, it is advised to use JobScheduler for background updates. Unfortunately, there are limitations. The periodic updates of JobService can not be called in less than 15 minutes intervals. The moment JobService.onStartJob() is unpredictable. We may miss the exact moment to update the minute digit (59th second). Prior O we used to run a background service with Handler.postDelayed() to update the time in the widget. In O the background service can be terminated by the system. How

Clarification of setUpdateCurrent on OneOffTask

一世执手 提交于 2019-12-03 16:39:15
I'm trying to wrap my head around the behaviour of setTag and setUpdateCurrent of OneoffTask in the GcmNetworkManager tooling. The documentation of setUpdateCurrent says this: Optional setter to specify whether this task should override any preexisting tasks with the same tag. This defaults to false, which means that a new task will not override an existing one. Fair enough, but it doesn't say what will happen to a task, it only says one thing that will not happen - i.e. the task will not overridden. :) It's not clear to me if using setUpdateCurrent means that duplicate tasks are allowed of it