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

Is there any way to point location in Google map as Location written in EditText by user android
Android SDK 22.6 Malfunctions
android app installed but not able to see
How to retain instance when orientation change while communicating with server
Cannot start new project with Android Studio
Using getExternalFilesDir with multi SDCards (Galaxy S3)
Facebook Conceal .so files not uploading in Android Project
android simple facebook returning “cancelled by user” when trying to share a post
Create or Open native Google documents using GoogleDriveApi
Android How To create RadioButtons like a row of Buttons
HorizontalScrollView “Style” not working on 1.6 or 2.1?
How to start an activity from child android thread?
SimonVT/MessageBar supply layout_width attribute
Select multiple tables like a partial dump
How to get timeline posts details from Facebook in android
Change text in searchview

Categories

HOME
google-app-engine
polymer
object
depth
angular2-material
flex
numbers
pascal
yandex
spring-data-mongodb
tivoli
permissions
zip
android-json
vert.x
accessibility
pattern-matching
google-schemas
ibeacon-android
fhir
heap
php-5.6
openbugs
libc
stellar.js
searchview
null-pointer
google-data-studio
sencha-touch
inno-download-plugin
exit
game-theory
itunes
jquery-multiselect
bulletphysics
motion-detection
flooding
android-maps
linked-data
realm-mobile-platform
testcomplete
userdefaults
gitlab-api
paragraph
deltaspike
code-snippets
jett
classcastexception
sharding
sql-delete
processwire
docfx
lint
sql-server-ce
sessionstorage
kill
levenshtein-distance
portforwarding
ssrs-2014
bindingnavigator
apollostack
show-hide
getchar
mschart
truezip
cup
mach-o
google-photos
rsa-archer-grc
rmongo
dotnetnuke-7
resourcemanager
macaulay2
gogs
jtwig
stream-processing
nio2
jparsec
blitline
jnlua
linklabel
pypiserver
microsoft-reporting
flock
opserver
evolus-pencil
ember-cli-rails
wso2greg
dronekit-android
rdflib
skspritenode
avahi
at-job
sip-server
formview
mutual-authentication
vbe
font-awesome-4.0.0
cascadingdropdown
http-status-code-410
resource-management
booksleeve
nokia-s40
iboutlet
objectquery
fitbounds
flex-mobile
entitydatasource
tournament
photolibrary
diagrams
ruby-1.8
maven-1
lobo-cobra

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