• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 Copyright 2017 The Android Open Source Project
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<sample>
18    <name>PictureInPicture</name>
19    <group>Media</group>
20    <package>com.example.android.pictureinpicture</package>
21    <minSdk>"android-O"</minSdk>
22
23    <strings>
24        <intro>
25            This sample demonstrates basic usage of Picture-in-Picture mode for handheld devices.
26            The sample plays a video. The video keeps on playing when the app is turned in to
27            Picture-in-Picture mode. On Picture-in-Picture screen, the app shows an action item to
28            pause or resume the video.
29        </intro>
30    </strings>
31
32    <template src="base-build"/>
33
34    <metadata>
35        <status>PUBLISHED</status>
36        <categories>Media, Android O Preview</categories>
37        <technologies>Android</technologies>
38        <languages>Java</languages>
39        <solutions>Mobile</solutions>
40        <level>ADVANCED</level>
41        <icon>screenshots/icon-web.png</icon>
42        <screenshots>
43            <img>screenshots/1-main.png</img>
44            <img>screenshots/2-pip.png</img>
45        </screenshots>
46        <api_refs>
47            <android>android.app.PictureInPictureArgs</android>
48            <android>android.app.RemoteAction</android>
49            <android>android.app.PendingIntent</android>
50        </api_refs>
51
52        <description>
53            <![CDATA[
54This sample demonstrates basic usage of Picture-in-Picture mode for handheld devices.
55The sample plays a video. The video keeps on playing when the app is turned in to
56Picture-in-Picture mode. On Picture-in-Picture screen, the app shows an action item to
57pause or resume the video.
58]]>
59        </description>
60
61        <intro>
62            <![CDATA[
63The O Developer Preview allows activities to launch in Picture-in-Picture (PiP) mode. PiP is a
64special type of [multi-window][1] mode mostly used for video playback. PiP mode is already available
65for [Android TV][2]; the O Developer Preview makes the feature available on other Android devices.
66
67The app is *paused* when it enters PiP mode, but it should continue showing content. For this
68reason, you should make sure your app does not pause playback in its [onPause()][3]
69handler. Instead, you should pause video in [onStop()][4]. For more information, see [Multi-Window
70Lifecycle][5].
71
72To specify that your activity can use PIP mode, set `android:supportsPictureInPicture` to `true` in
73the manifest. (Beginning with the O Developer Preview, you do not need to set
74`android:resizeableActivity` to `true` if you are supporting PIP mode, either on Android TV or on
75other Android devices; you only need to `setrandroid:resizeableActivity` if your activity supports
76other multi-window modes.)
77
78You can pass a [PictureInPictureArgs][6] to [enterPictureInPictureMode()][7] to specify how an
79activity should behave when it is in PiP mode. You can also use it to call
80[setPictureInPictureArgs()][8] and update the current behavior. If the app is in not PiP mode, it
81will be used for later call of [enterPictureInPictureMode()][7].
82
83With a [PictureInPictureArgs][6], you can specify aspect ratio of PiP activity and action items
84available for PiP mode. The aspect ratio is used when the activity is in PiP mode. The action items
85are used as menu items in PiP mode. You can use a [PendingIntent][9] to specify what to do when the
86item is selected.
87
88[1]: https://developer.android.com/guide/topics/ui/multi-window.html
89[2]: https://developer.android.com/training/tv/playback/picture-in-picture.html
90[3]: https://developer.android.com/reference/android/app/Activity.html#onPause()
91[4]: https://developer.android.com/reference/android/app/Activity.html#onStop()
92[5]: https://developer.android.com/guide/topics/ui/multi-window.html#lifecycle
93[6]: https://developer.android.com/reference/android/app/PictureInPictureArgs.html
94[7]: https://developer.android.com/reference/android/app/Activity.html#enterPictureInPictureMode(android.app.PictureInPictureArgs)
95[8]: https://developer.android.com/reference/android/app/Activity.html#setPictureInPictureArgs(android.app.PictureInPictureArgs)
96[9]: https://developer.android.com/reference/android/app/PendingIntent.html
97]]>
98        </intro>
99    </metadata>
100
101</sample>
102