Pro Android with Kotlin


Download 5.42 Mb.
Pdf ko'rish
bet120/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   116   117   118   119   120   121   122   123   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile

136
CHAPTER 8: APIs
Table 8-3. JobDispatcher Options
Method
Description
setService(Class)
This is the job class (in Kotlin you must write MyService::class.
java).
setTag(String)
This uniquely identifies the job.
setRecurring(Boolean)
This sets whether this is a recurring job.
setLifetime(Int)
This sets the lifetime of the job. Possible values are Lifetime.
FOREVER and Lifetime.UNTIL_NEXT_BOOT. With FOREVER, the job will 
persist even after a device reboot.
setTrigger(Trigger)
This sets when to trigger the job. Possible values are as follows:
• Trigger.NOW: Starts the job immediately
• Trigger.executionWindow(windowStart: Int, windowEnd: Int): 
Sets an execution window (in seconds)
• Trigger.contentUriTrigger(uris: List): Watches 
content URIs
setReplaceCurrent(Boolean)
This specifies whether to replace an existing job, provided it has the 
same tag.
setRetryStrategy( 
RetryStrategy)
This sets the retry strategy. Possible values are as follows:
• RetryStrategy.DEFAULT_EXPONENTIAL: Exponential, as in 30s, 
1min, 2min, 4min, 8min, and so on.
• RetryStrategy.DEFAULT_LINEAR: Linear, as in 30s, 60s, 90s, 120s, 
and so on.
setConstraints(vararg Int)
Here you can set constraints that need to be satisfied for the job to 
run. Possible values are as follows:
• Constraint.ON_ANY_NETWORK: Run only if a network is available.
• Constraint.ON_UNMETERED_NETWORK: Run only if an unmetered 
network is available.
• Constraint.DEVICE_CHARGING: Run only if the device is plugged in.
• Constraint.DEVICE_IDLE: Run only if the device is idle.
setExtras(Bundle)
Use this to set extra data. These will be passed to onStartJob()
in the job service class.



Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   116   117   118   119   120   121   122   123   ...   223




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling