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

This website is not available”. “ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY” Android
How do i get a list of markers add to a map in android without a hash or using a array
Unable to connect to firebaseio.com
Perform operations in SQL database when alarm fires (access from reciever)
How to display Screen when device goes in sleep mode(screen off) android?
Guidelines for “rounded” icon in Android 7.1
How to listen to when all RecyclerView items are added?
Location Object has lat lng of another city
What is server side adaption?
Android emulator not working with local server
facebook api version used in facebook android sdk
How to connect WebSocket to Android Applicaton?
TextView: display text in preview only, not during runtime [duplicate]
Application crashing while loading PDF file usin MUPDF in android application
Can we implement an Horizontal list in Appwidget?
Android databinding : how can I bind a layout identifier to include

Categories

HOME
scikit-learn
google-spreadsheet
formal-languages
requirements
spring-data-redis
knitr
vscode-extensions
rom
permissions
angularfire2
barcode
special-characters
rcloud
openpyxl
datastage
xcodebuild
ipmitool
jsonpath
spring-social
radgridview
zerobrane
android-intent
microsoft-dynamics-nav
google-container-registry
connector
topology
blade
ksh
href
backpack-for-laravel
angular-routing
qliksense
draft-js-plugins
definitelytyped
browser-sync
boost-asio
deltaspike
jmockit
fstream
papaparse
parse-tree
demo
spring-mvc-test
trigonometry
plaintext
movilizer
tcc
android-exoplayer
signal-strength
jide
vaadin-elements
yii2-api
arq
modelsim
subnet
arules
mouseleave
filenet
polyline
webjars
dimension
simevents
cda
uiactionsheet
kendo-upload
contentcontrol
terracotta
xenomai
morton-number
rate-limiting
xvim
doctype
liquid-layout
typeconverter
node-serialport
procedural-programming
jbake
structuremap3
raygun
mobility
template-deduction
matrix-inverse
buffering
vbe
process-explorer
facebook-timeline
cakephp-1.2
subgraph
boost-signals
apache-whirr
gobject-introspection
workflow-services
http-daemon
cdonts
mtu
openfaces
opml
unmanagedresources
information-management
mathematical-typesetting
pnrp

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile