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

How do I create a gallery within a custom adapter?
How to upload the image to server in android phonegap
Unable to get Status of Check boxes as a child element of ListView Item
Autocomplete dropdown item text color in Theme.Holo.Light issue
Issues about Alarm Manager in Android
OpenGL ES 1.0 strange behavior for textures with gradients
Android login page throwing NullPointerException
Customs for submitting changes to an open source project? [closed]
Javah cannot find khronos.opengles.GL10
GridView items: set relative sizes
How can I generate a String Array for a ListView using conditionals to determine if the String elements should be on the List?
Getting data from Listview with BaseAdapter
Android How to implement services for time delayed actions?
Android InApp Billing gives RESULT_ERROR most of the time
Does Android 2.x support QVGA resolution?
Where is my database file in SQLite

Categories

HOME
google-app-engine
beautifulsoup
developer-tools
ng-idle
c99
telegram
wakanda
zend-framework
mstest
r-googlesheets
replace
3d-reconstruction
naivebayes
http-post
internationalization
symfony-2.8
mathprog
android-7.0-nougat
cfml
replication
cgbitmapcontext
ckfinder
nstimer
linked-data
angular-translate
paperjs
errbot
comparable
winpe
alm
kudu
openerp-7
filesystemwatcher
opensmpp
mcustomscrollbar
dcmtk
linqpad
logback-groovy
outputcache
nanoc
jboss-4.2.x
builder
yii2-api
user-defined-fields
corruption
spring-data-couchbase
backbone-collections
mouseleave
jtree
docpad
spring-cloud-feign
model-associations
mapinfo
vorpal.js
udpclient
nullable
jbase
directdraw
page.js
binomial-theorem
sapscript
ember-cli-rails
dulwich
keyup
omnifaces
google-refine
typeconverter
kubuntu
rrule
umlgraph
actionfilterattribute
administration
machine-instruction
xml-dsig
square-bracket
conditionaltagsupport
xmltodict
breakout
flex++
octal
traceability
cascadingdropdown
dopostback
tree-balancing
iboutlet
objectquery
cgimage
google-floodlight
umra
ruby-1.8
easyb
pagemethods
feasibility
windows-identity
application-planning
sqlobject
int64
blind

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