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 path between my location to destination from input
How to include extra fragments onto a ViewPager, in Android?
android launch another app resume screen in programmatically
How to stop or cancel Mediaplayer.setOnPreparedListener form executing Android
Why is the email Intent not working from Common (non Activity) class
How can I send automatic SMS using android apps?
How to enable Design View (GUI) for xml files other than the layout xml in Android Studio?
Menu does not behave as expected
Android studio cannot resolve a symbol
Android ShapeDrawable set Background and Border programmatically
Video played on GlSurfaceView hangs for 500ms every 16 or 17 frames
cordova plugins conflict on android platform
Performing get/post from server for JSON response in android
How to add configuration file to android studio in windows?
Why does this code get me a “Cannot find symbol” error when I declare the method in this page?
Android device not showing alert in response to remote push notification when the app is not running

Categories

HOME
phpword
adal
apache-flink
youtube-data-api-v3
yahoo-finance
battery
mstest
nuget
aws-cli
alsa
parameters
telegram-bot
limit
zip
special-characters
sendgrid-api-v3
syntaxnet
project
emoji
supervisor
screen-readers
mathprog
fileserver
gmm
microsoft-ocr
user-experience
php-mysqlidb
event-store
custom-post-type
underscore.js
8051
bringtofront
jaws
calculation
testbed
playstation-portable
code-snippets
reactjs.net
baidu-map
navigator
raft
swagger-php
salesforce-communities
openproject
zoomify
password-protection
mongoose-schema
jide
vaadin-elements
servermanager
fwrite
openresty
jquery-ui-draggable
user-defined-fields
twilio-click-to-call
boo
payload
flac
macaulay2
synonym
tooleap
stream-processing
bizagi
project-organization
cda
ellucian-scribe
thread-sleep
aspen
blitline
java-money
fuelcms
lasso
botan
diff3
nodelist
mruby
jbake
filesplitting
browserify-shim
punycode
matrix-inverse
cfcache
ecslidingviewcontroller
ora-06550
kendo-dataviz
breakout
dtmf
hidapi
database-create
apache-commons-dbutils
update-statement
presentation-layer
uideviceorientation
scrollbars
django-piston
visualj#
linfu-dynamicproxy
flvplayback
business-model

Resources

Encrypt Message