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
910
いまさらWorkManager
2019/1/28に開催されたPotatotips #58にて発表した資料です
Yoshihiro WADA
January 28, 2019
Tweet
Share
More Decks by Yoshihiro WADA
See All by Yoshihiro WADA
AndroidデバイスにFTPサーバを建立する
e10dokup
0
470
Gradleの実行環境設定を見直す
e10dokup
0
1.1k
Firebase App Distributionのテストアプリ配信を試しやすくする
e10dokup
0
640
アプリに署名する 〜GitHub ActionsでのCIも見据えて〜
e10dokup
0
1.2k
Profileable buildでより正確なパフォーマンスを掴む
e10dokup
0
750
[DroidKaigi 2021] メディアアクセス古今東西 / Now and Future of Media Access
e10dokup
0
3.7k
今更「dp」を考える / Let's think about "dp" now
e10dokup
0
5.7k
1から学ぶAndroidアプリデバッグ - アプリの動作を追いかけよう / Learn Android application debugging from the scratch - track apps' behaviors
e10dokup
10
3.3k
Guide to background processingを読んでみる / Reading "Guide to background processing"
e10dokup
0
260
Other Decks in Programming
See All in Programming
新世界の理解
koriym
0
140
サイトを作ったらNFCタグキーホルダーを爆速で作れ!
yuukis
0
490
Oracle Database Technology Night 92 Database Connection control FAN-AC
oracle4engineer
PRO
1
180
GitHub Copilotの全体像と活用のヒント AI駆動開発の最初の一歩
74th
8
3.2k
TDD 実践ミニトーク
contour_gara
0
140
Introduction to Git & GitHub
latte72
0
120
未来を拓くAI技術〜エージェント開発とAI駆動開発〜
leveragestech
2
180
Dart 参戦!!静的型付き言語界の隠れた実力者
kno3a87
0
210
TROCCO×dbtで実現する人にもAIにもやさしいデータ基盤
nealle
0
330
あのころの iPod を どうにか再生させたい
orumin
2
2.5k
Claude Codeで実装以外の開発フロー、どこまで自動化できるか?失敗と成功
ndadayo
2
1.3k
書き捨てではなく継続開発可能なコードをAIコーディングエージェントで書くために意識していること
shuyakinjo
1
300
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
1k
Agile that works and the tools we love
rasmusluckow
329
21k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.4k
We Have a Design System, Now What?
morganepeng
53
7.7k
It's Worth the Effort
3n
187
28k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Documentation Writing (for coders)
carmenintech
73
5k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
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