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
870
いまさら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
770
Firebase App Distributionのテストアプリ配信を試しやすくする
e10dokup
0
530
アプリに署名する 〜GitHub ActionsでのCIも見据えて〜
e10dokup
0
1.1k
Profileable buildでより正確なパフォーマンスを掴む
e10dokup
0
690
[DroidKaigi 2021] メディアアクセス古今東西 / Now and Future of Media Access
e10dokup
0
3.3k
今更「dp」を考える / Let's think about "dp" now
e10dokup
0
5.4k
1から学ぶAndroidアプリデバッグ - アプリの動作を追いかけよう / Learn Android application debugging from the scratch - track apps' behaviors
e10dokup
10
3.1k
Guide to background processingを読んでみる / Reading "Guide to background processing"
e10dokup
0
250
よしなに頑張る画像ロードの話 / image load mettya tsurai
e10dokup
2
470
Other Decks in Programming
See All in Programming
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
Go の GC の不得意な部分を克服したい
taiyow
2
770
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
270
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
170
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
200
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
nekko cloudにおけるProxmox VE利用事例
irumaru
3
430
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
130
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
2
460
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
100
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
45
7k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Statistics for Hackers
jakevdp
796
220k
It's Worth the Effort
3n
183
28k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Making Projects Easy
brettharned
116
5.9k
We Have a Design System, Now What?
morganepeng
51
7.3k
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