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
Yoshihiro WADA
January 28, 2019
Programming
1
860
いまさらWorkManager
2019/1/28に開催されたPotatotips #58にて発表した資料です
Yoshihiro WADA
January 28, 2019
Tweet
Share
More Decks by Yoshihiro WADA
See All by Yoshihiro WADA
Gradleの実行環境設定を見直す
e10dokup
0
640
Firebase App Distributionのテストアプリ配信を試しやすくする
e10dokup
0
470
アプリに署名する 〜GitHub ActionsでのCIも見据えて〜
e10dokup
0
990
Profileable buildでより正確なパフォーマンスを掴む
e10dokup
0
670
[DroidKaigi 2021] メディアアクセス古今東西 / Now and Future of Media Access
e10dokup
0
3.1k
今更「dp」を考える / Let's think about "dp" now
e10dokup
0
5.2k
1から学ぶAndroidアプリデバッグ - アプリの動作を追いかけよう / Learn Android application debugging from the scratch - track apps' behaviors
e10dokup
10
3k
Guide to background processingを読んでみる / Reading "Guide to background processing"
e10dokup
0
240
よしなに頑張る画像ロードの話 / image load mettya tsurai
e10dokup
2
450
Other Decks in Programming
See All in Programming
rails_girls_is_my_gate_to_join_the_ruby_commuinty
maimux2x
0
190
Amazon BedrockでサーバレスなAIお料理ボットを作成する!!
tosuri13
0
210
ドメイン駆動設計を実践するために必要なもの
bikisuke
3
330
いつか使える ObjectSpace / Maybe useful ObjectSpace
euglena1215
2
130
null or undefined
susisu
23
6.2k
Swiftコードバトル必勝法
toshi0383
0
150
Rubyとクリエイティブコーディングの輪の広がり / The Growing Circle of Ruby and Creative Coding
chobishiba
1
260
REXML改善のその後
naitoh
0
190
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
2
110
メモリ最適化を究める!iOSアプリ開発における5つの重要なポイント
yhirakawa333
0
410
Desafios e Lições Aprendidas na Migração de Monólitos para Microsserviços em Java
jessilyneh
2
140
私のEbitengineの第一歩
qt_luigi
0
440
Featured
See All Featured
Designing with Data
zakiwarfel
98
5k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.4k
Building Adaptive Systems
keathley
36
2.1k
Design by the Numbers
sachag
277
19k
Fontdeck: Realign not Redesign
paulrobertlloyd
80
5.1k
From Idea to $5000 a Month in 5 Months
shpigford
379
46k
Embracing the Ebb and Flow
colly
83
4.4k
How to name files
jennybc
75
98k
Fashionably flexible responsive web design (full day workshop)
malarkey
401
65k
Web Components: a chance to create the future
zenorocha
308
42k
Happy Clients
brianwarren
96
6.6k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
663
120k
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