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
0
68
Work, Work - WorkManager
Slided from my presentation on WorkManager at the DutchAUG IO Extended Extended meetup.
Hugo Visser
July 19, 2018
Tweet
Share
More Decks by Hugo Visser
See All by Hugo Visser
LLMs on Small devices [DutchAUG]
hugovisser
1
110
Modern Android dependency injection
hugovisser
1
250
Android dependency injection in 2022
hugovisser
1
170
Open the door!
hugovisser
0
48
Navigating the Navigation Component
hugovisser
1
130
Reactive UIs with Data Binding
hugovisser
2
150
Up close and personal with Nearby (DevFest Trondheim)
hugovisser
0
71
Up close and personal with Nearby
hugovisser
3
460
Room: the blessed object mapper
hugovisser
0
190
Other Decks in Technology
See All in Technology
Wasmで社内ツールを作って配布しよう
askua
0
120
増え続ける脆弱性に立ち向かう: 事前対策と優先度づけによる 持続可能な脆弱性管理 / Confronting the Rise of Vulnerabilities: Sustainable Management Through Proactive Measures and Prioritization
nttcom
1
160
データエンジニアリング 4年前と変わったこと、 4年前と変わらないこと
tanakarian
2
360
CSPヘッダー導入で実現するWebサイトの多層防御:今すぐ試せる設定例と運用知見
llamakko
1
210
そもそも AWS FIS について。なぜ今 FIS のハンズオンなのか?などなど
kazzpapa3
2
120
ゼロから始めるSREの事業貢献 - 生成AI時代のSRE成長戦略と実践 / Starting SRE from Day One
shinyorke
PRO
0
230
From Live Coding to Vibe Coding with Firebase Studio
firebasethailand
1
110
低レイヤソフトウェア技術者が YouTuberとして食っていこうとした話
sat
PRO
7
5.8k
「手を動かした者だけが世界を変える」ソフトウェア開発だけではない開発者人生
onishi
11
4.3k
AIを使っていい感じにE2Eテストを書けるようになるまで / Trying to Write Good E2E Tests with AI
katawara
3
1.6k
今日からあなたもGeminiを好きになる
subaruhello
1
560
The Madness of Multiple Gemini CLIs Developing Simultaneously with Jujutsu
gunta
1
2.5k
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
173
14k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
47
9.6k
Facilitating Awesome Meetings
lara
54
6.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
530
A better future with KSS
kneath
238
17k
The Pragmatic Product Professional
lauravandoore
35
6.8k
How STYLIGHT went responsive
nonsquared
100
5.6k
How to train your dragon (web standard)
notwaldorf
96
6.1k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Testing 201, or: Great Expectations
jmmastey
43
7.6k
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