Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
実用 Picture in Picture
aosa4054
June 18, 2019
Programming
2
580
実用 Picture in Picture
aosa4054
June 18, 2019
Tweet
Share
More Decks by aosa4054
See All by aosa4054
Now in Android Overview
aosa4054
0
370
LazyVerticalGridに学ぶ 非スクローラブルなグリッドの作り方
aosa4054
0
410
自作アプリのアイコンを作った話
aosa4054
0
130
Other Decks in Programming
See All in Programming
大規模プロダクトにLinterを導入し運用している話
hirokiotsuka
0
300
Better Angular Architectures: Architectures with Standalone Components @DWX2022
manfredsteyer
PRO
1
360
Isar勉強会
hoddy3190
0
310
Atomic Design とテストの○○な話
takfjp
2
790
ふんわり理解するcontext
rukiadia
1
180
リーダブルテストコード / #vstat
jnchito
46
34k
Google I/O 2022 Android関連概要 / Google I/O 2022 Android summary
phicdy
0
360
More Than Micro Frontends: 3 Further Use Cases for Module Federation @DWX 2022
manfredsteyer
PRO
0
340
JetpackCompose 導入半年で感じた 改善点
spbaya0141
0
140
Babylon.jsで作ったsceneをレイトレーシングで映えさせる
turamy
1
200
閱讀原始碼 - 再戰十年的 jQuery
eddie
1
280
Cloudflare WorkersでGoのHTTPサーバーを動かすライブラリを作った話
syumai
0
140
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
498
130k
Side Projects
sachag
450
37k
10 Git Anti Patterns You Should be Aware of
lemiorhan
638
52k
Learning to Love Humans: Emotional Interface Design
aarron
261
37k
Visualization
eitanlees
125
12k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
21
1.4k
The Mythical Team-Month
searls
210
39k
Clear Off the Table
cherdarchuk
79
290k
Git: the NoSQL Database
bkeepers
PRO
415
59k
Raft: Consensus for Rubyists
vanstee
127
5.5k
How to Ace a Technical Interview
jacobian
266
21k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
224
49k
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/