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
実用 Picture in Picture
Search
aosa4054
June 18, 2019
Programming
2
850
実用 Picture in Picture
aosa4054
June 18, 2019
Tweet
Share
More Decks by aosa4054
See All by aosa4054
Now in Android Overview
aosa4054
1
1.3k
LazyVerticalGridに学ぶ 非スクローラブルなグリッドの作り方
aosa4054
0
730
自作アプリのアイコンを作った話
aosa4054
0
230
Other Decks in Programming
See All in Programming
オープンセミナー2025@広島「君はどこで動かすか?」アンケート結果
satoshi256kbyte
0
230
複雑なドメインに挑む.pdf
yukisakai1225
4
890
コンテキストエンジニアリング Cursor編
kinopeee
1
740
Claude Codeで挑むOSSコントリビュート
eycjur
0
190
More Approvers for Greater OSS and Japan Community
tkikuc
1
110
Rancher と Terraform
fufuhu
2
170
FindyにおけるTakumi活用と脆弱性管理のこれから
rvirus0817
0
350
AHC051解法紹介
eijirou
0
640
MCPでVibe Working。そして、結局はContext Eng(略)/ Working with Vibe on MCP And Context Eng
rkaga
4
620
Honoアップデート 2025年夏
yusukebe
1
890
機能追加とリーダー業務の類似性
rinchoku
0
180
レガシープロジェクトで最大限AIの恩恵を受けられるようClaude Codeを利用する
tk1351
4
1.5k
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
42
2.8k
Facilitating Awesome Meetings
lara
55
6.5k
Visualization
eitanlees
147
16k
Making the Leap to Tech Lead
cromwellryan
134
9.5k
The Pragmatic Product Professional
lauravandoore
36
6.8k
Code Review Best Practice
trishagee
70
19k
Faster Mobile Websites
deanohume
309
31k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.9k
RailsConf 2023
tenderlove
30
1.2k
Code Reviewing Like a Champion
maltzj
525
40k
A designer walks into a library…
pauljervisheath
207
24k
Transcript
実⽤ Picture in Picture 2019.06.18 Shota Ara Mirrativ, Inc. ©
2019 Mirrativ, Inc. potatotips #62
99 ⾃⼰紹介
Shota Ara • Internship @Mirrativ • Android app dev •
Twitter: aosa4054(あおさ) • GitHub: aosa4054
99 Picture in Pictureとはなんぞや
動画です!
端末の設定に⾶ぶ 閉じる 拡⼤して元の画⾯に戻る RemoteAction(複数設定可) Picture in Picture画⾯の詳細
• 画⾯に⼩さいウインドウを出せる • 別のアプリを使いながらでも あるアプリを⾒続けられる • PIP中は限定された動作しかできない
• Android O以上 • Android TVのみNougatからでも使える • パーミッションを取る必要なし • 設定からユーザーが無効にすることができる
99 どうやるのか
enterPictureInPictureMode(PictureInPictureParams.Builder().build())
PictureInPictureParams.Builder
PictureInPictureParams.Builder Rational型の引数を渡して PIP画⾯の縦横⽐を指定できる
PictureInPictureParams.Builder IconとPendingIntentを含むRemoteActionを渡して PIP画⾯におけるアクションを設定できる。
PictureInPictureParams.Builder IconとPendingIntentを含むRemoteActionを渡して PIP画⾯におけるアクションを設定できる。 BroadCastReceiverで 購読すれば処理が可能
PictureInPictureParams.Builder 左右上下どの辺に寄りやすいか を指定できる
99 タスクとライフサイクル
通常のタスクとライフサイクル onCreate onStart onResume onPause onStop onDestroy 同⼀のタスクで⾏われる
Picture in Pictureのタスクとライフサイクル 当該Activityのみ別タスクへ enterPictureInPictureMode(PictureInPictureParams.Builder().build()) onPictureInPictureModeChanged onPictureInPicturModeChanged(isInPictureInPictureMode: Boolean)
Picture in Pictureのタスクとライフサイクル onPictureInPictureModeChanged(true) onStop onResume onPictureInPictureModeChanged(false) return dismiss onPause
Picture in Pictureのタスクとライフサイクル onPictureInPictureModeChanged(true) onResume onPictureInPictureModeChanged(false) return dismiss onPause onStop
onDestroyは呼ばれずに タスクも残り続ける
• ユーザーからすると 「消したはずのアプリがタスクに残り続けてる、、なんで?」 「同じアプリがタスクに⼆つあるんだけど、、」 となる • 復帰時とDismiss時で別々の処理を⾏えない • Activity. isInPictureInPictureModeというフラグはあるが
これではタイミングの問題でハンドリングできない なにが問題か
onPictureInPictureModeChanged(true) onStop onResume onPictureInPictureModeChanged(false) Activity. isInPictureInPictureMode = true onPause
なにが問題か • ユーザーからすると 「消したはずのアプリがタスクに残り続けてる、、なんで?」 「同じアプリがタスクに⼆つあるんだけど、、」 となる • 復帰時とDismiss時で別々の処理を⾏えない • 別にフラグを作って管理するしかない
onPictureInPictureModeChanged(true) onPictureInPictureModeChanged(false) こっちのタイミングでフラグを 管理することでonResume, onStop内で 復帰時とdismiss時で別々の処理をできる onResume onStop onPause
onPictureInPictureModeChanged(true) onPictureInPictureModeChanged(false) こっちのタイミングでフラグを 管理することでonResume, onStop内で 復帰時とdismiss時で別々の処理をできる onResume onPause onStop if(fromPictureInPicture)
finishAndRemoveTask() とか……
99 めんどい
99 フラグ管理をいい感じにするライブラリを作りました https://github.com/aosa4054/ PictureInPictureLifecycleObserver
99 PR
https://www.mirrativ.co.jp/recruit/