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

onItemLongClick help required android listitem
How to stop a Media Player of another application?
EditText.getText().toString() shows error
fetching data in parallel [closed]
ListView is messed up
Alternative Jersey Android
What is difference between 'debug.keystore' and 'release.keystore' in Android?
onMenuItemClick invoked several times
Android folding animation in facebook like slider
tab layout in android
Delphi Android Memory Leak(or another slowdown)
How can I fix GradientDrawable cannot be cast to ColorDrawable issue?
google maps OutOfMemory
Unable to set notifyDataSetChanged in Android
Move/drag/zoom an imageview in Android
Android grid layout auto adjust

Categories

HOME
beautifulsoup
fuelux
ggplot2
apache-jena
redux-form
case
flex
jelastic
requirements
spring-data-redis
nuget
scripting
android-json
data-visualization
performancepoint
fosrestbundle
project
g++
x-cart
qsqlquery
http-post
atlassian-stash
vuejs
asp.net-mvc-viewmodel
mapstruct
bourbon
question2answer
r-mice
beta
draft-js-plugins
itunes
errbot
bioinformatics
vex
twiml
nsurl
constexpr
dst
hard-drive
sammy.js
dynamic-jasper
getpixel
python-import
jwplayer6
roblox
ideascript
z-notation
filesystemwatcher
verifiable-c
stringtokenizer
postgresql-8.4
naming
movilizer
claims
smoothstate.js
apollostack
proget
amq
semantic-logging
otp
er-diagram
flyout
cmp
structuremap4
ziparchive
vulcanize
wso2developerstudio
dimension
vorpal.js
clipboard.js
riot
angular-ui-typeahead
thread-sleep
realsense
toast
boomerang
linklabel
rpart
airbrake
nsurlsessiondatatask
cakephp-2.7
qtwebengine
procedural-programming
cryptographichashfunction
cosine-similarity
filesplitting
sip-server
sonarqube-5.0
wcm
human-computer-interface
mintty
wxformbuilder
ray
ora-06550
sphinxql
ie8-compatibility-mode
cffile
dolby-audio-api
josql
usertype
infobright
agility.js
entity-attribute-value
filemerge
google-ajax-api
xui
load-time
office-2007
message-passing
application-verifier
application-planning
linfu-dynamicproxy
dsoframer
httpcookie
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