Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
実用 Picture in Picture
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
aosa4054
June 18, 2019
Programming
940
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
実用 Picture in Picture
aosa4054
June 18, 2019
Transcript
29 slides
実⽤ 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/
More Decks by aosa4054
See All by aosa4054
Now in Android Overview
aosa4054
1
1.5k
LazyVerticalGridに学ぶ 非スクローラブルなグリッドの作り方
aosa4054
0
820
自作アプリのアイコンを作った話
aosa4054
0
260
Other Decks in Programming
See All in Programming
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
300
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
340
エージェントの管理もエージェントに – herdr-core と自作バックログで作る司令塔 –
nearme_tech
PRO
1
120
手の動かし方がわからなかった私が個人開発者になるまで
usagi0920_pochi
0
340
Ruby から Emacs を操作したい
phigasui
0
390
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
150
はじめてのPLATEAU
nokonoko1203
1
670
Crash Auto Pipelines
veronikapj
1
450
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
120
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
230
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
130
AIエージェントの「テストは通るのに本番で壊れる」を減らす
shibuiwilliam
3
120
Featured
See All Featured
AI: The stuff that nobody shows you
jnunemaker
PRO
12
1.3k
Deep Space Network (abreviated)
tonyrice
0
430
Digital Ethics as a Driver of Design Innovation
axbom
PRO
2
560
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
360
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
2
4k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
970
Leo the Paperboy
mayatellez
11
2.5k
The Cost Of JavaScript in 2023
addyosmani
56
10k
Heart Work Chapter 1 - Part 1
lfama
PRO
11
37k
Accessibility Awareness
sabderemane
1
310