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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
hideoohashi
November 15, 2018
Programming
1.6k
2
Share
Android 8.0のPush受信時のサービス起動について
hideoohashi
November 15, 2018
More Decks by hideoohashi
See All by hideoohashi
SmartNews 5.0 ちょっと苦労した話 / shibuya.apk #19
hideoohashi
5
4.8k
Other Decks in Programming
See All in Programming
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
590
TiDBのアーキテクチャから学ぶ分散システム入門 〜MySQL互換のNewSQLは何を解決するのか〜 / tidb-architecture-study
dznbk
1
190
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
4
1.2k
Vibe NLP for Applied NLP
inesmontani
PRO
0
490
PHP で mp3 プレイヤーを実装しよう
m3m0r7
PRO
0
290
Programming with a DJ Controller — not vibe coding
m_seki
3
250
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
160
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
210
From Formal Specification to Property Based Test
ohbarye
0
380
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
260
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
4
360
NakouPAY説明用
annouim0
0
270
Featured
See All Featured
The SEO identity crisis: Don't let AI make you average
varn
0
450
Tell your own story through comics
letsgokoyo
1
900
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
SEO for Brand Visibility & Recognition
aleyda
0
4.5k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
My Coaching Mixtape
mlcsv
0
110
Automating Front-end Workflow
addyosmani
1370
200k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
240
The Invisible Side of Design
smashingmag
303
52k
Ruling the World: When Life Gets Gamed
codingconduct
0
210
Code Review Best Practice
trishagee
74
20k
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