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
430
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
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
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
770
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
300
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
310
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
930
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
バグを見つけた?それAppleに直してもらおう!
uetyo
0
180
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
150
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
YesSQL, Process and Tooling at Scale
rocio
169
14k
GraphQLとの向き合い方2022年版
quramy
44
13k
A designer walks into a library…
pauljervisheath
204
24k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
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