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

will the Unity3D monetisation through ads work while i put no physical adresse in my Unity profile nor my Google play developpers console?
Simulate a mouse click
Attempt to invoke virtual method 'java.lang.String example.asuspc.prospect.model.UserModel.getPhoto_profile()' on a null object reference
Sending Post Request to URL with json object Data and Headers from Android
Android calendar header shows wrong month-year in material-calendarview
Using PC keyboard commands through an Android app
Is it possible to Inflate RemoteViews in other application?
Java - How to hold two keys at same time?
HTML email Android Outlook app text having weird justification issues
Xamarin Wizard Project Can't Debug
Clicking Children Item in Sliding Panel triggers parent first?
MPAndroid Chart same chart width
Inside fragment ViewPager takes long time to load child fragment
Staggered Gridview (Recycleview) with load more functionality inside the NestedScrollView
Android How to move the image using sensors based on image size
Using Fragment default transition- not working properly

Categories

HOME
django
oracle12c
fuelux
time-complexity
wakanda
youtube-data-api-v3
oracle-apex-5
owl-carousel
database-normalization
alsa
nested-if
interpolation
echo
openpyxl
opengl-es-3.0
supervisor
nancy
selenium-ide
mongodb-csharp
firefox-addon
symfony-console
shortest-path
charles
asp.net-core-webapi
string-concatenation
short-url
google-api-client
perlbrew
itunes
subclass
openmdao
calculation
corenlp-server
userdefaults
eviews
event-flow
volatile
mailkit
hunspell
getlasterror
odroid
demo
softmax
movilizer
microsoft-metro
tcc
placeholder
wc
facebook-social-plugins
vaadin-elements
sonarlint-eclipse
dtsearch
identification
google-cse
arq
amq
android-testing
avx
boo
payload
cd-burning
pocketsphinx-android
udpclient
cassia
project-organization
nupic
false-sharing
httpruntime.cache
dynatree
file-move
jdi
.bash-profile
atoi
typemock
branch-and-bound
linked-tables
typeconverter
git-ftp
uvc
adehabitathr
grouping-sets
packet-sniffers
psr-4
strawberry-perl
gii
create.js
ray
spring-remoting
paste
terminate
windows-embedded-standard
solace-mq
sphinxql
embedded-fonts
code-duplication
tlf
server-administration
cascadingdropdown
curb
qi4j
xcelsius
ajax-polling
qtabbar
fail-fast-fail-early

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