android


Back-off for a fixed period with JobScheduler


What I am trying to achieve is:
Three (may increase) JobServices are scheduled.
Each job keeps invoking on a difference set of RESTful APIs from a service until it decides to end.
The service API has an hourly quota limitation, and will return a certain code when invoked too frequently.
The quota is calculated for each application, meaning invocations by all three jobs are counted as a whole.
When a job receives the error code indicating the quota is exceeded, it stops running and wait for re-schedule.
Since the quota is hourly basis, the job only needs to wait for 60 minutes for the cool-down.
To test the back-off strategy, I had an experiment building the job like this:
new JobInfo.Builder(JOB_ID, new ComponentName(this, QuickJob.class))
.setOverrideDeadline(ONE_MINUTE)
.setMinimumLatency(HALF_MINUTE)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.build();
Basicly what the QuickJob does is it logs the timestamp, calls jobFinished(params, true) and waits for Android to reschedule.
From the logs I could see that the first time the job stopped for approximately 1 minute, second time 2 minutes, then it's 4 minutes, 8, ..., which fits the description of the BACKOFF_POLICY_LINEAR policy.
However, in my case, as described in the beginning, I only need the job to back-off for an hour, not 1, 2, 4, 8 hours.
I thought about triggering the jobs at the start of every hour with AlarmManager, but I think it's nice to have the network type settings over the jobs.
Another possible solution I thought about is to have the jobs call jobFinished() with needsReschedule being false, but schedule themselves to run again in the next hour. But this just feels hacky and not... right.
So what are my choices now?

Related Links

Gallery Not Showing Content
Your APK's version code needs to be higher than xxx phonegap
Everyplay not working in android vesion 5.1
GoogleApi Real Time Multiplayer pushing updates
How to pass value from onItemSelected to another spinner
OnItemClickListener for horizontal gridview
Saving canvas draw in bitmap showing white screen
How to cut off an unused space in a custom view?
How to create alerts using alarm manager and background service call and a web service call inside background service?
ActionBar menu with text ,icon,text
Firebase endAt() not working with date string?
Different splash screen on screen orientation
Visual Studio 2015. AXML. Doesn't work intellisence inside view with warning
Generate content to display on an ePaper display from Android App
Fingerprint detection stop work after the app goes to pause
Gradle: “Empty” Android project takes half a minute to compile (Android Studio)

Categories

HOME
xml
c99
mjml
youtube-data-api-v3
serialization
saml-2.0
spring-data-mongodb
soa
google-apps
cq5
telegram-bot
regular-language
google-cloud-datalab
banner
lanczos
recordrtc
teechart
qpython
g++
google-schemas
libc
frequency-distribution
flatpak
internationalization
job-scheduling
red5
swagger-2.0
selinux
joptionpane
object-storage
expressionengine3
pylons
nstimer
intersystems-cache
soot
wcag
xbox
livelink
recurring-events
mustache
database-comparison
login-script
android-maps-extensions
pop3
timing
railstutorial.org
linq-to-objects
microsoft-metro
sonarlint-eclipse
serde
robomongo
manova
bluez
context-switch
jqchart
mach-o
cpu-cache
offline.js
ampps
filenet
choice
gets
rocks
delta
vorpal.js
lean
project-organization
cycle2
spring-retry
tfs-workitem
doctype
linked-tables
nutiteq
fail2ban
shopizer
phpldapadmin
nodelist
iiop
addressing-mode
genymotion-call
paw
personalization
android-usb
unit-of-work
kogrid
time.h
fb.ui
fusefabric
jdb
database-create
ikimagebrowserview
fsevents
tournament
strsep
resharper-6.0
vs-android
feasibility
dsl-tools
ifilter
pbcopy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App