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
それ CLI フレームワークがなくてもできるよ / Building CLI Tools Without Frameworks
orgachem
PRO
17
3.8k
バイブコーディング × 設計思考
nogu66
0
110
なぜあなたのオブザーバビリティ導入は頓挫するのか
ryota_hnk
5
590
Terraform やるなら公式スタイルガイドを読もう 〜重要項目 10選〜
hiyanger
12
3k
Understanding Kotlin Multiplatform
l2hyunwoo
0
250
Claude Code と OpenAI o3 で メタデータ情報を作る
laket
0
120
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
710
AHC051解法紹介
eijirou
0
410
パスタの技術
yusukebe
1
270
DynamoDBは怖くない!〜テーブル設計の勘所とテスト戦略〜
hyamazaki
0
200
React 使いじゃなくても知っておきたい教養としての React
oukayuka
18
5.5k
ゲームの物理
fadis
3
980
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Agile that works and the tools we love
rasmusluckow
329
21k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.4k
Practical Orchestrator
shlominoach
190
11k
We Have a Design System, Now What?
morganepeng
53
7.7k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.6k
Done Done
chrislema
185
16k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.6k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6k
Fireside Chat
paigeccino
38
3.6k
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/