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
700
Firebase App Distributionのテストアプリ配信を試しやすくする
e10dokup
0
490
アプリに署名する 〜GitHub ActionsでのCIも見据えて〜
e10dokup
0
1k
Profileable buildでより正確なパフォーマンスを掴む
e10dokup
0
670
[DroidKaigi 2021] メディアアクセス古今東西 / Now and Future of Media Access
e10dokup
0
3.2k
今更「dp」を考える / Let's think about "dp" now
e10dokup
0
5.3k
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
460
Other Decks in Programming
See All in Programming
推し活としてのrails new/oshikatsu_ha_iizo
sakahukamaki
3
1.7k
gopls を改造したら開発生産性が高まった
satorunooshie
8
240
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
480
ECSのサービス間通信 4つの方法を比較する 〜Canary,Blue/Greenも添えて〜
tkikuc
11
2.3k
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
920
デプロイを任されたので、教わった通りにデプロイしたら障害になった件 ~俺のやらかしを越えてゆけ~
techouse
52
32k
飲食業界向けマルチプロダクトを実現させる開発体制とリアルな現状
hiroya0601
1
400
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
230
僕がつくった48個のWebサービス達
yusukebe
18
17k
Vitest Browser Mode への期待 / Vitest Browser Mode
odanado
PRO
2
1.7k
Outline View in SwiftUI
1024jp
1
160
約9000個の自動テストの 時間を50分->10分に短縮 Flakyテストを1%以下に抑えた話
hatsu38
23
11k
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
88
5.7k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
How to Think Like a Performance Engineer
csswizardry
19
1.1k
Speed Design
sergeychernyshev
24
570
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Docker and Python
trallard
40
3.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.4k
Embracing the Ebb and Flow
colly
84
4.4k
Making Projects Easy
brettharned
115
5.9k
Adopting Sorbet at Scale
ufuk
73
9k
Into the Great Unknown - MozCon
thekraken
31
1.5k
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