Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5970ec4 authored by Dan Yu's avatar Dan Yu Committed by Android (Google) Code Review
Browse files

Merge "docs: Adding section about single task activity for playback with PIP" into mnc-mr-docs

parents aced1701 c5d9c8f1
Loading
Loading
Loading
Loading
+27 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@ Picture-in-picture</a></li>
  <li><a href="#handling_ui">Handling UI During Picture-in-picture</a>
  <li><a href="#handling_ui">Handling UI During Picture-in-picture</a>
</li>
</li>
  <li><a href="#continuing_playback">Continuing Video Playback While in
  <li><a href="#continuing_playback">Continuing Video Playback While in
Picture-in-picture</a></li>
  <li><a href="#single_playback">Using a Single Playback Activity for
Picture-in-picture</a></li>
Picture-in-picture</a></li>
  <li><a href="#best">Best Practices</a></li>
  <li><a href="#best">Best Practices</a></li>
</ol>
</ol>
@@ -170,6 +172,31 @@ public void onPause() {
<p>When your activity switches out of PIP mode back to full-screen mode, the
<p>When your activity switches out of PIP mode back to full-screen mode, the
system resumes your activity and calls your <code>onResume()</code> method.</p>
system resumes your activity and calls your <code>onResume()</code> method.</p>


<h2 id="single_playback">Using a Single Playback Activity for
Picture-in-picture</h2>

<p>In your app, a user might select a new video when browsing for content on
the main screen, while a video playback activity is in PIP mode. Play the new
video in the existing playback activity in full screen mode, instead of
launching a new activity that might confuse the user.</p>

<p>To ensure a single activity is used for video playback requests and
switched into or out of PIP mode as needed, set the activity's
<code>android:launchMode</code> to <code>singleTask</code> in your manifest:
</p>

<pre>
&lt;activity android:name="VideoActivity"
    ...
    android:supportsPictureInPicture="true"
    android:launchMode="singleTask"
    ...
</pre>

<p>In your activity, override {@link android.app.Activity#onNewIntent
Activity.onNewIntent()} and handle the new video, stopping any existing video
playback if needed.</p>

<h2 id="best">Best Practices</h2>
<h2 id="best">Best Practices</h2>


<p>PIP is intended for activities that play full-screen video. When switching
<p>PIP is intended for activities that play full-screen video. When switching