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 to draw multiple texts on canvas
Can i build Linphone in Android Studio on Mac?
Why can't I find aSmack in Maven Central?
Set Screen Orientation in Android app / Cordova 3.5
Best practice on loading images from servers [closed]
Google Cloud Endpoint send Image Base 64
GCM registration number to database
Material design refresh icon change?
Where to store android application configuration to survive un/reinstall
Android Studio stuck while building application
How to increase the number of friends in Facebook Android App Request Dialog
Testing release and proguarded version of Android app - NoSuchMethodError
Android HCE: are there rules for AID?
Android hiding keyboard with imeoptions
bitmap height and width auto scaled for drawable from res folders but not for drawable created from URL
Mobile DB app off line from internet

Categories

HOME
awk
codenvy
rendering
opendj
echo
polling
crystal-reports-2013
frontend
teechart
openstreetmap
gson
rtf
php-5.6
symbol
vuejs
git-extensions
bourbon
boost-icl
selinux
mount
data.stackexchange.com
google-cloud-print
interbase
flooding
android-maps
tpm
iis-express
twiml
jbutton
github3.py
imagenet
sim-card
ods
diacritics
cin
doc
apriori
android-ibeacon
wc
stylecop
monkey-testing
dotnet-httpclient
wcftestclient
git-flow
skin
django-1.10
structuremap4
file-uri
qiime
rasterize
highland.js
themoviedb-api
batik
lasso
zscript
sql-scripts
easyrtc
teaspoon
tweenlite
strawberry-perl
unix-socket
ss7
reflector
lnk
android-framework
terminate
git-repo
ie8-compatibility-mode
breakout
windows-phone-8-sdk
model-driven-development
ice-cube
cocoalibspotify-2.0
kogrid
flex++
scmmanager
insert-id
chart-director
vfs
cakephp-1.2
rmiregistry
floating-point-exceptions
urlrewriter
google-floodlight
http-daemon
codebase
twitterizer
presentation-layer
luajava
instantiationexception
updatesourcetrigger
maven-1
drupal-fivestar
django-piston
wysiwym
fdf
soappy
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