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
59
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
79
Modern Android dependency injection
hugovisser
1
240
Android dependency injection in 2022
hugovisser
1
150
Open the door!
hugovisser
0
34
Navigating the Navigation Component
hugovisser
1
110
Reactive UIs with Data Binding
hugovisser
2
120
Up close and personal with Nearby (DevFest Trondheim)
hugovisser
0
56
Up close and personal with Nearby
hugovisser
3
360
Room: the blessed object mapper
hugovisser
0
180
Other Decks in Technology
See All in Technology
事前準備が肝!AI活用のための業務改革
layerx
PRO
1
400
2024年のナビゲーション・フォーカス対応:Composeでキーボード・ナビゲーションをサポートしよう
tahia910
0
110
『GRANBLUE FANTASY: Relink』専任エンジニアチームで回す大規模開発QAサイクル
cygames
0
110
リアルお遍路+SORACOM IoT
ozk009
1
140
ついに出た!OpenAIの最新モデル「o1」って何がすごいの?
minorun365
PRO
3
1.3k
『GRANBLUE FANTASY Relink』ソフトウェアラスタライザによる実践的なオクルージョンカリング
cygames
0
180
LINEヤフーのフロントエンド組織・体制の紹介
lycorp_recruit_jp
1
1.2k
再考 アクターモデル/ reconsider actor model
ytake
0
370
『GRANBLUE FANTASY: Relink』クオリティと物量の両立に挑戦したフェイシャルアニメーション事例 ~カットシーンからランタイムまで~
cygames
0
120
サーバレスでモバイルアプリ開発! NTTコム「ビジネスdアプリ」のアーキテクチャ / The architecture of business d app
nttcom
12
250
不動産 x AIことはじめ~データの真価を拓くために
estie
0
130
Jetpack Compose Modifier 徹底解説 / Jetpack Compose Modifier
wiroha
0
210
Featured
See All Featured
For a Future-Friendly Web
brad_frost
174
9.3k
[RailsConf 2023] Rails as a piece of cake
palkan
48
4.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
48
2.8k
GraphQLの誤解/rethinking-graphql
sonatard
65
9.8k
Bootstrapping a Software Product
garrettdimon
PRO
304
110k
Raft: Consensus for Rubyists
vanstee
136
6.5k
How to train your dragon (web standard)
notwaldorf
85
5.6k
Building Better People: How to give real-time feedback that sticks.
wjessup
359
19k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
32k
The Language of Interfaces
destraynor
153
23k
The Cost Of JavaScript in 2023
addyosmani
42
5.7k
Documentation Writing (for coders)
carmenintech
65
4.3k
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