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.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
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
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
480
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
RubyLSPのマルチバイト文字対応
notfounds
0
120
CSC509 Lecture 09
javiergs
PRO
0
140
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
250
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
cmp.Or に感動した
otakakot
3
200
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
169
14k
A better future with KSS
kneath
238
17k
Navigating Team Friction
lara
183
14k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
For a Future-Friendly Web
brad_frost
175
9.4k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Designing the Hi-DPI Web
ddemaree
280
34k
Embracing the Ebb and Flow
colly
84
4.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
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