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 set button's setOnClickListener correctly?
Set digit key listener on edit text android?
CCTMXTiledMap rendered in incorrect position - iOS, Android and Win32
Converting ios project to android using phonegap
i just doing a simple android project for employee register. when running i got this logcat errors…please help me solve this problems [closed]
Service with BatteryStateChangeBroadcastReceiver and Notification not working
Is it possible to calculate degree of rotaion of phone using accelerometer values i.e rotation matrix in android?
Swipe views with icons instead of text
Having problems getting the metadata for Spotify songs
Android Target API [closed]
RelativeLayout within GridView
updating existing contact details in android
Is it possible to display an EditText widget on the Action Bar without inflating from an xml resource?
Out of memory error in BitmapFactory
Issues building openssl for Android
Configure WebViews for Debugging - Where?

Categories

HOME
azure-stream-analytics
jax-rs
character-encoding
pascal
battery
knitr
pyqt4
google-admin-sdk
nfs
commonjs
ibeacon-android
fhir
mod-security
automatic-ref-counting
zerobrane
docx
altera
alpacajs
scsi
esoteric-languages
dimensional-modeling
symbols
asciidoctor-pdf
ag
string-concatenation
visual-studio-extensions
exit
comparator
gmock
perlbrew
ms-access-web-app
rpgle
ntp
constexpr
dotspatial
eviews
android-maps-extensions
reverse
lubridate
getlasterror
navigator
servicestack-text
openproject
imagenet
jpad
gdata
loading
metawidget
opensmpp
urlsession
spring-mvc-test
c9.io
sharp-snmp
x++
pom.xml
arq
semantic-logging
appdomain
git-flow
mach-o
monkey
trigger.io
branch-prediction
webjars
qtplugin
watch-os-2
http-status-code-401
cda
kiosk
decimalformat
lazybones
phonertc
opserver
skspritenode
jquery-forms-plugin
zxspectrum
qtwebengine
at-job
boost-program-options
formview
mobility
named-parameters
ignite-ui
codeplex
diem
cascadingdropdown
zope.interface
filemerge
google-ajax-api
rowlex
application-verifier
information-management

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