Reputation: 543
In my app I need to update user location by Geofire every 15 minutes continiously,but I am confused with some parameters.Currently I have
JobScheduler jobScheduler = (JobScheduler) getActivity().getSystemService(Context.JOB_SCHEDULER_SERVICE);
JobInfo.Builder builder = new JobInfo.Builder(AppConstants.USER_DATA_UPDATE_JOB_ID, new ComponentName(getActivity().getPackageName(), UserDataUpdateScheduler.class.getName()));
builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
builder.setPeriodic(900000);
builder.setPersisted(true);
jobScheduler.schedule(builder.build());
What exactly indicates jobScheduler to start job again builder.setPeriodic(900000);
or jobFinished(params, true);
? And also can't understand the meanings of onStartJob
and onStopJob
return values.
Also an additional question,in Android O a background service cannot receive location updates more than a few times per hour.So approxiamtely how much is that few times?
Upvotes: 0
Views: 127
Reputation: 29
setPeriodic(long intervalMillis)
Specify that this job should recur with the provided interval, not more than once per period the MinimumInterval for this method is 15 minutes or 900000 milliseconds And
JobFinished
call when your job is Finished
(if your task is short write on onStart method and return false without calling JobFinished method )
note: if you define Your Job Periodic in jobFinished always return false
Upvotes: 0
Reputation: 5600
setPeriodic(long intervalMillis)
Specify that this job should recur with the provided interval, not more than once per period.In others words, this job must repeat with the interval assigned, in milis, 9000 = 9 seconds.
JobFinished
Call this to inform the JobScheduler that the job has finished its work. When the system receives this message, it releases the wakelock being held for the job.
Upvotes: 1