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
Android 8.0のPush受信時のサービス起動について
Search
hideoohashi
November 15, 2018
Programming
2
1.5k
Android 8.0のPush受信時のサービス起動について
hideoohashi
November 15, 2018
Tweet
Share
More Decks by hideoohashi
See All by hideoohashi
SmartNews 5.0 ちょっと苦労した話 / shibuya.apk #19
hideoohashi
5
4.6k
Other Decks in Programming
See All in Programming
More Approvers for Greater OSS and Japan Community
tkikuc
1
110
さようなら Date。 ようこそTemporal! 3年間先行利用して得られた知見の共有
8beeeaaat
2
1.3k
1から理解するWeb Push
dora1998
7
1.7k
TanStack DB ~状態管理の新しい考え方~
bmthd
2
480
Putting The Genie in the Bottle - A Crash Course on running LLMs on Android
iurysza
0
120
Ruby Parser progress report 2025
yui_knk
1
300
testingを眺める
matumoto
1
130
Azure SRE Agentで運用は楽になるのか?
kkamegawa
0
1.5k
フロントエンドのmonorepo化と責務分離のリアーキテクト
kajitack
2
160
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
260
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
110
Go言語での実装を通して学ぶLLMファインチューニングの仕組み / fukuokago22-llm-peft
monochromegane
0
120
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Making Projects Easy
brettharned
117
6.4k
Typedesign – Prime Four
hannesfritz
42
2.8k
What's in a price? How to price your products and services
michaelherold
246
12k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
Speed Design
sergeychernyshev
32
1.1k
Unsuck your backbone
ammeep
671
58k
Scaling GitHub
holman
463
140k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
800
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
910
Transcript
Android 8.0のPush受信時の サービス起動について 2018/11/15 - potatotips #56 Hideo Ohashi 1
About Me • Androidエンジニア8年間やってます • 現在はスマートニュース株式会社でAndroidアプ リ開発全般に関わっています 2
Today’s topic • Android 8.0対応時に発生した、Push受信時の バックグラウンドサービス起動の問題と、そこか ら学んだことの共有させていただきたいと思いま す 3
バックグラウンドサービスの制限 • Android 8.0からバックグラウンドサービスの実 行に制限がつきました ◦ https://developer.android.com/about/versions/oreo/background • ただし特定の状況のときは実行制限はなくなり、 優先度高のPush受信もそのうちのひとつです
4
状況 • SmartNewsではPushを受けた後に処理を Serviceに委譲し、別途画像を取得して Notificationを出していました • Android8.0でもそのままで動作するはずが、 startService()の呼び出しで IllegalStateExceptionが発生していました 5
なぜだろうか? 6
原因(たぶん) • 試しに優先度高のPushを受けてから60秒ほど 経った後にstartService()を呼び出したら IllegalStateExceptionが発生しました • onReceive()では基本的にstartService()を呼び 出しているだけなので、Pushを受けてからアプリ のonReceive()が呼ばれるまでの、アプリ側から 手が出せないところで時間がかかってしまってい
る可能性が高い 7
どう解決したか • Serviceを使っていた理由は主に画像ダウン ロードだったので、startService()に失敗した場 合は画像なしでNotificationを出すことで解決さ せました ◦ 多少の情報は落ちてもリアルタイムに表示することを優 先させました 8
まとめ • 何かPushを受けてバックグラウンドサービスを 動かしたいとき、優先度高のPushでも startService()が失敗する場合があることを考え て設計・実装したほうがよさそう 9
ご静聴ありがとうございました 10