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
いまさらWorkManager
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yoshihiro WADA
January 28, 2019
Programming
960
1
Share
いまさらWorkManager
2019/1/28に開催されたPotatotips #58にて発表した資料です
Yoshihiro WADA
January 28, 2019
More Decks by Yoshihiro WADA
See All by Yoshihiro WADA
AndroidデバイスにFTPサーバを建立する
e10dokup
0
1.1k
Gradleの実行環境設定を見直す
e10dokup
0
1.3k
Firebase App Distributionのテストアプリ配信を試しやすくする
e10dokup
1
720
アプリに署名する 〜GitHub ActionsでのCIも見据えて〜
e10dokup
0
1.3k
Profileable buildでより正確なパフォーマンスを掴む
e10dokup
0
780
[DroidKaigi 2021] メディアアクセス古今東西 / Now and Future of Media Access
e10dokup
0
3.9k
今更「dp」を考える / Let's think about "dp" now
e10dokup
0
5.9k
1から学ぶAndroidアプリデバッグ - アプリの動作を追いかけよう / Learn Android application debugging from the scratch - track apps' behaviors
e10dokup
10
3.6k
Guide to background processingを読んでみる / Reading "Guide to background processing"
e10dokup
0
300
Other Decks in Programming
See All in Programming
Kubernetesでセルフホストが簡単なNewSQLを求めて / Seeking a NewSQL Database That's Simple to Self-Host on Kubernetes
nnaka2992
0
200
Coding as Prompting Since 2025
ragingwind
0
710
ローカルで稼働するAI エージェントを超えて / beyond-local-ai-agents
gawa
1
250
今からFlash開発できるわけないじゃん、ムリムリ! (※ムリじゃなかった!?)
arkw
0
180
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2.3k
Radical Imagining - LIFT 2025-2027 Policy Agenda
lift1998
0
230
PHP でエミュレータを自作して Ubuntu を動かそう
m3m0r7
PRO
2
170
「効かない!」依存性注入(DI)を活用したAPI Platformのエラーハンドリング奮闘記
mkmk884
0
300
The free-lunch guide to idea circularity
hollycummins
0
410
Goの型安全性で実現する複数プロダクトの権限管理
ishikawa_pro
2
1.4k
条件判定に名前、つけてますか? #phperkaigi #c
77web
2
950
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
150
Featured
See All Featured
Visualization
eitanlees
150
17k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
500
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
How STYLIGHT went responsive
nonsquared
100
6k
What's in a price? How to price your products and services
michaelherold
247
13k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
700
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Embracing the Ebb and Flow
colly
88
5k
GitHub's CSS Performance
jonrohan
1032
470k
Un-Boring Meetings
codingconduct
0
250
Transcript
WorkManager Yoshihiro Wada a.k.a. @e10dokup 2019/1/28 at Potatotips #58
a.k.a. e10dokup CyberAgent Inc. Ameba
None
2018/12/23 - 1.0.0-beta01 2019/1/15 1.0.0-beta02 2018/12/12 - 1.0.0-alpha13 Breaking Change
Codelabs WorkManager
Android Jetpack compileSdkVersion 28 API Play Services JobScheduler/AlermManager/ FirebaseJobDispatcher etc
WorkManager
Worker WorkManager WorkRequest Worker Request WorkManager Request WorkManager WorkManager WorkRequest
extends Worker doWork() Worker.Result.success() / failure() Worker class MyWorker( context:
Context, params: WorkerParameters ) : Worker(context, params) { override fun doWork(): Worker.Result { // Կ͔͠Βͷॲཧ return Worker.Result.success() } }
Worker Data build setInputData set Worker getInputData WorkRequest // WorkerʹΛ༩͑Δ
val data = Data.Builder().putString("KEY", "VALUE").build() OneTimeWorkRequest.Builder(MyWorker::class.java) .setInputData(data) .build() // WorkerͰΛऔΓग़͢ getInputData().getString("KEY")
OneTimeWorkRequest Worker Request PeriodicWorkRequest Worker Request WorkRequest
WorkManager#enqueue WorkRequest workManager = WorkManager.getInstance() val data = Data.Builder().putString("KEY", "VALUE").build()
val request = OneTimeWorkRequest.Builder(MyWorker::class.java) .setInputData(data) .build() workManager.enqueue(request)
WorkManager#beginWith Continuation then Work Continuation#enqueue Work // AWorker -> BWorker
-> CWorkerͷॱʹ࣮ߦ͞Ε͍ͯ͘WorkContinuation val continuation = workManager.beginWith(OneTimeWorkRequest.from(AWorker::class.java)) continuation.then(OneTimeWorkRequest.from(BWorker::class.java)) continuation.then(OneTimeWorkRequest.from(CWorker::class.java)) continuation.enqueue()
WorkManager#beginUniqueWork ExistingWorkPolicy REPLACE - KEEP - APPEND - Work -
var continuation = workManager.beginUniqueWork( "unique_work_id", ExistingWorkPolicy.REPLACE, OneTimeWorkRequest.from(AWorker::class.java) )
WorkRequest Constraint Work // ͕ॆిதͰ͋Δ੍ΛՃ͑Δ val constraints = Constraints.Builder() .setRequiresCharging(true)
.build() continuation = continuation.then( OneTimeWorkRequest.Builder(AWorker::class.java) .setConstraints(constraints) .build() )
NetWorkType - BatteryNotLow - Charging - StorageNotLow - DeviceIdle -
API23 Doze Idle Work
WorkRequest tag set WorkStatus uniqueId Continuation LiveData RxJava2 -> RxWorker
1.0.0-alpha12 Codelabs 2-3