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

textview to shift on another line if text is long
Get all Instagram feeds using londatiga library
Aquery some images are BLANk
Error: Hook failed with error code 1:
Cannot insert image using android studio
As used in combination CollapsingToolbarLayout, Toolbar and Navigation Drawer?
cordova camera copyFile error code 1000
Button click event with Custom List view
Try is working porperly but catch is given error
GCM for Android- unable to unsubscribe from a topic
Get all installations using parse.com
How to use a function in Android that was only available earlier API Levels?
Gradle Build Errors?
Dark-blue file names in Android Studio
Android cursor.getInt
Android - Direction Routing by defined coordinates using GPS

Categories

HOME
phpword
oracle12c
polymer
forms
jmx
composite-primary-key
knitr
settings
spring-session
android-json
jax-ws
odoo-8
teechart
pattern-matching
android-securityexception
stellar.js
magnetic-cards
altera
package-managers
symfony-console
replication
href
dataflow-diagram
php-mysqlidb
slidetoggle
fat
jackson-modules
handler
tizen-tv
deltaspike
glib
memory-address
android-sugarorm
card.io
hibernate-search
pdw-file-browser
searchkit
apiary.io
magento-1.9.2.4
watchman
amazon-ses
snapchat
textsum
automapper-5
vugen
identification
google-cse
magic-draw
arules
libjpeg
lsyncd
monkey
pybrain
pure-css
pytables
actor-platform
latin
lrs
udpclient
mediametadataretriever
beanstalk
false-sharing
piracy-prevention
asyncdisplaykit
highland.js
maybe
toran-proxy
morton-number
visual-sourcesafe-2005
uncompress
dulwich
liquid-layout
dnssec
cwrsync
snackbar
kubuntu
grouping-sets
ignite-ui
template-deduction
terminate
decoupling
android-audiorecord
accesscontrolexception
mysql-error-1044
cocoalibspotify-2.0
nebula
abstract-data-type
pagedown
http-status-code-410
virtual-pc
wimax
extreme-programming
fragmenttransaction
inkcanvas
ilasm
jquery-address
luabind
filemerge
listactivity
webdev.webserver
cgbitmapcontextcreate
event-receiver
jqueryform
technical-debt
mathematical-typesetting

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