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
Realtime API 入門
riofujimon
0
110
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
110
レガシーな Android アプリのリアーキテクチャ戦略
oidy
1
170
Server Driven Compose With Firebase
skydoves
0
400
役立つログに取り組もう
irof
26
8.7k
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
350
PLoP 2024: The evolution of the microservice architecture pattern language
cer
PRO
0
1.6k
Tuning GraphQL on Rails
pyama86
2
1k
offers_20241022_imakiire.pdf
imakurusu
2
360
Vue3の一歩踏み込んだパフォーマンスチューニング2024
hal_spidernight
3
3.1k
Googleのテストサイズを活用したテスト環境の構築
toms74209200
0
270
約9000個の自動テストの 時間を50分->10分に短縮 Flakyテストを1%以下に抑えた話
hatsu38
23
11k
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
Designing for humans not robots
tammielis
249
25k
Art, The Web, and Tiny UX
lynnandtonic
296
20k
Producing Creativity
orderedlist
PRO
341
39k
Unsuck your backbone
ammeep
668
57k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Optimizing for Happiness
mojombo
376
69k
Fireside Chat
paigeccino
32
3k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
What's in a price? How to price your products and services
michaelherold
243
12k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
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