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.7k
Other Decks in Programming
See All in Programming
株式会社 Sun terras カンパニーデック
sunterras
0
310
2分台で1500examples完走!爆速CIを支える環境構築術 - Kaigi on Rails 2025
falcon8823
3
3.7k
dynamic!
moro
10
8k
Railsだからできる 例外業務に禍根を残さない 設定設計パターン
ei_ei_eiichi
0
900
Web Components で実現する Hotwire とフロントエンドフレームワークの橋渡し / Bridging with Web Components
da1chi
3
2.5k
uniqueパッケージの内部実装を支えるweak pointerの話
magavel
0
1k
What's new in Spring Modulith?
olivergierke
1
150
Things You Thought You Didn’t Need To Care About That Have a Big Impact On Your Job
hollycummins
0
230
ソフトウェア設計の実践的な考え方
masuda220
PRO
4
590
組込みだけじゃない!TinyGo で始める無料クラウド開発入門
otakakot
0
270
Go言語はstack overflowの夢を見るか?
logica0419
0
330
はじめてのDSPy - 言語モデルを『プロンプト』ではなく『プログラミング』するための仕組み
masahiro_nishimi
2
480
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
53
7.8k
The World Runs on Bad Software
bkeepers
PRO
72
11k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.5k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
8
910
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
GraphQLとの向き合い方2022年版
quramy
49
14k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
How to train your dragon (web standard)
notwaldorf
97
6.3k
Bash Introduction
62gerente
615
210k
RailsConf 2023
tenderlove
30
1.2k
Typedesign – Prime Four
hannesfritz
42
2.8k
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