Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Work, Work - WorkManager
Search
Hugo Visser
July 19, 2018
Technology
110
0
Share
Work, Work - WorkManager
Slided from my presentation on WorkManager at the DutchAUG IO Extended Extended meetup.
Hugo Visser
July 19, 2018
More Decks by Hugo Visser
See All by Hugo Visser
LLMs on Small devices [DutchAUG]
hugovisser
1
150
Modern Android dependency injection
hugovisser
1
280
Android dependency injection in 2022
hugovisser
1
230
Open the door!
hugovisser
0
79
Navigating the Navigation Component
hugovisser
1
170
Reactive UIs with Data Binding
hugovisser
2
170
Up close and personal with Nearby (DevFest Trondheim)
hugovisser
0
110
Up close and personal with Nearby
hugovisser
3
510
Room: the blessed object mapper
hugovisser
0
220
Other Decks in Technology
See All in Technology
基礎から解説!Icebergで紐解くSnowflake×Databricks連携の現在地
cm_yasuhara
0
380
データ分析基盤の信頼を支える視点と設計
yuki_saito
2
760
開発を止めない CI/CD ~CI Visibilityによる継続的最適化~
pensuke628
0
180
ビジュアルプログラミングIoTLT vol.23
1ftseabass
PRO
0
150
AI駆動開発でなんでもハンズオン環境をつくってみた
yoshimi0227
0
170
Claude Codeですべての日常業務を爆速化しよう!
minorun365
PRO
16
15k
TROCCOで始めるクラウドコストを民主化するためのFinOps
tk3fftk
1
280
Sony_KMP_Journey_KotlinConf2026
sony
0
170
速さだけじゃない! VoidZero ツールが移行先に選ばれる理由
mizdra
PRO
6
660
テストコードのないプロジェクトにテストを根付かせる
tttol
0
220
管理アカウント単一運用からAWS Organizationsに移行するの大変で滅
hiramax
0
300
AI フレンドリーなエラー監視を TypeScript で実現する
shinyaigeek
2
160
Featured
See All Featured
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
340
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
210
Into the Great Unknown - MozCon
thekraken
41
2.5k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
200
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
160
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
370
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Everyday Curiosity
cassininazir
0
210
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.8k
Transcript
Work, work - WorkManager Hugo Visser @botteaap
[email protected]
None
None
WorkManager Part of architecture components, JetPack Schedules & execute jobs
“...intended for tasks that require a guarantee that the system will run them even if the app exits…”
Current options AlarmManager JobScheduler GCMNetworkManager FirebaseJobDispatcher
Current options AlarmManager → No system coordination, no constraints, throttled
JobScheduler GCMNetworkManager FirebaseJobDispatcher
Current options AlarmManager → No system coordination, no constraints, no
retries, throttled JobScheduler → API 21+, Coordination, constraints & retries, bugs < API 23 GCMNetworkManager FirebaseJobDispatcher
Current options AlarmManager → No system coordination, no constraints, no
retries, throttled JobScheduler → API 21+, Coordination, constraints & retries, bugs < API 23 GCMNetworkManager → JobSchedulerCompat, but not quite FirebaseJobDispatcher
Current options AlarmManager → No system coordination, no constraints, no
retries, throttled JobScheduler → API 21+, Coordination, constraints & retries, bugs < API 23 GCMNetworkManager → JobSchedulerCompat, but not quite FirebaseJobDispatcher → Pluggable schedulers, default: GCMNetworkManager
WorkManager Schedule jobs using constraints & retries JobScheduler on API
23+ AlarmManager or GCMNetworkManager through FJD < API 23
New features Reduce IPC → if a job is eligible
to run immediately, no need to “schedule” it. Monitor status → LiveData providing job status Unique jobs Tags Output parameters Orchestration of multiple jobs
Orchestration B runs after A D runs after C E
runs after B and D are completed
Unit of work: Worker import androidx.work.Worker class MyWorker: Worker() {
override fun doWork(): Result { // do the hard work return Result.SUCCESS // or Result.FAILURE or Result.RETRY } }
Schedule // work-runtime-ktx gives us a nicer kotlin syntax val
request = OneTimeWorkRequestBuilder<MyWorker>() .setConstraints(Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .build()) .build() // as of alpha4 getInstance() can return null! WorkManager.getInstance()!!.enqueue(request)
Monitor val status = WorkManager.getInstance()!!.getStatusById(request.id) status.observe(this, Observer { // WorkStatus
can be null if the task id is invalid or gone it?.let { Log.d(TAG, "Task status: ${it.state}") } })
Next? API still in flux Asynchronous workers Try it out,
file bugs https://issuetracker.google.com https://developer.android.com/topic/libraries/architecture/workmanager
Thanks! @botteaap
[email protected]
speakerdeck.com/hugovisser