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

Phonegap deviceready not responding/firing
How to prevent pixels from blending when enlarging images in ImageViews Android
Xperia Z emulator
How to pass a jpg id between activities Android
Android progress bar in ListView loading
Android Thread implementation for custom View
Customizing default android layouts
How to use systrace to profile disk I/O in Nexus10 running Android-4.2.1
How to send event from Service to Activity with Otto event bus?
Android Library project in Eclipse: RunTimeException ClassNotFoundException
sharedpreferences don't read button state
Problems with simple SQLite test in Android
How to get FragmentActivity reference inside an anonymous inner class of bindView method?
Integrate Android Login with ASP.NET website
Android Callback Method
System.exit(0) causes the Activity quit quickly when the app starts

Categories

HOME
url-redirection
notepad++
django
google-cloud-platform
localization
cobalt
time-complexity
ng-idle
fpga
pagination
pda
apiblueprint
rendering
pkcs#11
elasticsearch-5
performancepoint
sendgrid-api-v3
google-schemas
pega
activecollab
cmdb
gource
eip
android-intent
capistrano3
scsi
symfony-2.8
powershell-v5.0
microsoft-dynamics-nav
google-maps-autocomplete
angular-routing
imageresizer
object-storage
comparator
draft-js-plugins
mount
ckfinder
android-sharedpreferences
appirater
ms-access-2003
8051
rpgle
uitapgesturerecognizer
sqlpackage
winpe
mobx
record
r-grid
spring-security4
android-gridview
reactjs.net
carriage-return
sharepoint-workflow
apiary.io
raft
salesforce-communities
jpad
ods
azure-arm
branching-and-merging
contract
mesosphere
magento-2.0.7
tinymce-3
twilio-click-to-call
custom-font
static-cast
libjpeg
d3-force-directed
change-tracking
parfor
eigenvector
swizzling
cassia
omniauth-facebook
cda
exim4
jparsec
crouton-os
dynamics-nav-2016
dynatree
forwarding
django-urls
include-guards
sapscript
zscript
sha512
ejb-2.x
nodelist
mruby
jbake
browserify-shim
spy++
gii
rcaller
reflector
dot42
file-not-found
cfcache
gtm-oauth2
ie8-compatibility-mode
modular
jquery-1.9
composite-component
stacky
cardreader
fb.ui
booksleeve
extreme-programming
monotouch.dialog
httponly
cuteeditor
pos-for-.net
mathematical-notation
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