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 Stableに向けての所感
Search
Yoshihiro WADA
March 18, 2019
Programming
2
420
WorkManager Stableに向けての所感
2019/3/18に開催されたOtemachi.apk #2の発表資料です。当日はFirebaseJobDispatcher周りについて事実とは異なる発言をしているので修正したものになります。
Yoshihiro WADA
March 18, 2019
Tweet
Share
More Decks by Yoshihiro WADA
See All by Yoshihiro WADA
Gradleの実行環境設定を見直す
e10dokup
0
720
Firebase App Distributionのテストアプリ配信を試しやすくする
e10dokup
0
500
アプリに署名する 〜GitHub ActionsでのCIも見据えて〜
e10dokup
0
1.1k
Profileable buildでより正確なパフォーマンスを掴む
e10dokup
0
680
[DroidKaigi 2021] メディアアクセス古今東西 / Now and Future of Media Access
e10dokup
0
3.2k
今更「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
3k
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
みんなでプロポーザルを書いてみた
yuriko1211
0
260
Click-free releases & the making of a CLI app
oheyadam
2
110
as(型アサーション)を書く前にできること
marokanatani
10
2.6k
Better Code Design in PHP
afilina
PRO
0
120
Macとオーディオ再生 2024/11/02
yusukeito
0
370
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
ヤプリ新卒SREの オンボーディング
masaki12
0
130
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
290
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
役立つログに取り組もう
irof
28
9.6k
Featured
See All Featured
Site-Speed That Sticks
csswizardry
0
23
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
It's Worth the Effort
3n
183
27k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Transcript
WorkManager Stable Yoshihiro Wada a.k.a. @e10dokup Otemachi.apk #2 - 2019/03/18
2019/3/20
Yoshihiro Wada a.k.a. @e10dokup CyberAgant Inc. / Ameba Ameba
WorkManager
Android Jetpack compileSdkVersion 28 API Play Services JobScheduler/AlermManager/FirebaseJobDispatcher FirebaseJobDispatcher 1.0.0-alpha12
FirebaseJobDispatcher deprecated etc WorkManager
FirebaseJobDispatcher
None
WorkManager Stable 1.0.0 Released
Beta RC Stable bug x Breaking API Changes 2018/12/12 1.0.0-alpha13
Codelabs API Changes
WorkManager
Worker WorkManager WorkRequest Worker Request WorkManager Request WorkManager WorkManager WorkRequest
WorkManager
Worker doWork() WorkManager ˖ FYUFOET8PSLFSזؙٓأ甧ג ˖ EP8PSL ⰻד䗳銲זⳢ椚鎸鶢ׅ ˖ 䧭⸆٥㸣✪ח䘔ׄג8PSLFS3FTVMUTVDDFTT
GBJMVSF 鵤ׅ 8PSLFS class MyWorker( context: Context, params: WorkerParameters ) : Worker(context, params) { override fun doWork(): Worker.Result { // Կ͔͠Βͷॲཧ return Worker.Result.success() } }
WorkRequest optional Worker OneTimeWorkRequest - WorkRequest PeriodicWorkRequest - WorkRequest WorkManager
˖ 8PSLFSח㹋遤ח䗳銲ז⦼♷ִ ˖ %BUBؙٓأCVJME׃ךTFU*OQVU%BUBדTFUׅ ˖ 8PSLFS⩎דכHFU*OQVU%BUBד《⳿ׅ 8PSL3FRVFTU // WorkerʹΛ༩͑Δ val data = Data.Builder().putString("KEY", "VALUE").build() OneTimeWorkRequest.Builder(MyWorker::class.java) .setInputData(data) .build() // WorkerͰΛऔΓग़͢ getInputData().getString("KEY")
WorkManager WorkRequest enqueue WorkManager // Workerに値を与える val data = Data.Builder().putString(“KEY”,
“VALUE”).build() OneTimeWorkRequest.Builder(MyWorker::class.java) .setInputData(data) .build() // Workerで値を取り出す getInputData().getString(“KEY”) ˖ 8PSL.BOBHFSFORVFVFֽׅ 欰䧭׃8PSL3FRVFTUך㹋遤 workManager = WorkManager.getInstance() val data = Data.Builder().putString("KEY", "VALUE").build() val request = OneTimeWorkRequest.Builder(MyWorker::class.java) .setInputData(data) .build() workManager.enqueue(request)
potatotips 8PSL.BOBHFS :PTIJIJSP8BEBBLB!FEPLVQ BU1PUBUPUJQT ְתׁ https://bit.ly/2UF3k4Q
WorkManager Executor Constraints
DB Worker GreedyScheduler ThreadPool JobSchedulers createBestAvailableBackgroundScheduler API Level 23 JobSchedulers
Google Play Services FirebaseJobDispatcher AlermManager + BroadCastReceiver Executor ref: https://speakerdeck.com/takahirom/workmanager (58P)
DB Worker GreedyScheduler ThreadPool JobSchedulers createBestAvailableBackgroundScheduler API Level 23 JobSchedulers
AlermManager + BroadCastReceiver Executor ref: https://speakerdeck.com/takahirom/workmanager (58P)
Constraints WorkRequest Constraints ˖ 8PSL3FRVFTU⡲媮ꥡד$POTUSBJOU♷ִֿהד㹋遤儗חⵖ秈⸇ִ 8PSLך㹋遤朐䡾ⵖꣲ׃ְ // ͕ॆిதͰ͋Δ੍ΛՃ͑Δ val constraints
= Constraints.Builder() .setRequiresCharging(true) .build() continuation = continuation.then( OneTimeWorkRequest.Builder(AWorker::class.java) .setConstraints(constraints) .build() )
WorkManager Constraints NetworkType - BatterNotLow - Charging - StorageNotLow -
DeviceIdle - Doze Idle API23 Constraints
WorkManager Constraints NetworkType - BatterNotLow - Charging - StorageNotLow -
DeviceIdle - Doze Idle API23 Constraints ConstraintController Tracker Constraints
WorkManager Constraints NetworkType - BatterNotLow - Charging - StorageNotLow -
DeviceIdle - Doze Idle API23 Constraints ConstraintController Tracker Constraints
Constrains Builder Charging Constraints WorkManager TaskExecuter Worker WorkerFactory Tracker ConstraintController
Charging Constraint public @NonNull Builder setRequiresCharging(boolean requiresCharging) { this.mRequiresCharging = requiresCharging; return this; }
BatteryChargingController Room DB Charging Constraint BatteryChargingTracker ACTION_BATTERY_CHANGED intent ACTION_CHARGING /
ACTION_POWER_CONNECTED Tracker Constraint Back-o Worker Charging Constraint
https://android.googlesource.com/platform/frameworks/support/+/androidx- master-dev/work/workmanager/src/main/java/androidx/work/impl/constraints BatteryNotLow 15% ACTION_BATTERY_OKAY/LOW NetworkType ConnectivityManager METERED CONNECTED ROAMING
StorageNotLow ACTION_DEVICE_STORAGE_OK / LOW API 26 AndroidManifest BroadcastReceiver deprecated BroadcastReceiver Constraints
Executor Constraints Firebase JobDispatcher WorkManager migrating https://developer.android.com/topic/libraries/architecture/workmanager/ migrating-fb