• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

.google/23-Mar-2024-2015

app/23-Mar-2024-1,9921,225

gradle/wrapper/23-Mar-2024-65

screenshots/23-Mar-2024-

CONTRIBUTING.mdD23-Mar-20241.5 KiB3627

LICENSED23-Mar-202431.5 KiB648514

NOTICED23-Mar-2024614 1711

README.mdD23-Mar-20244.3 KiB9571

build.gradleD23-Mar-2024398 2319

gradle.propertiesD23-Mar-2024730 1813

gradlewD23-Mar-20244.9 KiB161120

gradlew.batD23-Mar-20242.3 KiB9166

proguard-rules.proD23-Mar-2024672 1815

settings.gradleD23-Mar-202415 21

README.md

1Android PictureInPicture Sample (Kotlin)
2===================================
3
4This sample demonstrates basic usage of Picture-in-Picture mode for handheld devices.
5The sample plays a video. The video keeps on playing when the app is turned in to
6Picture-in-Picture mode. On Picture-in-Picture screen, the app shows an action item to
7pause or resume the video.
8
9Introduction
10------------
11
12As of Android O, activities can launch in [Picture-in-Picture (PiP)][1] mode. PiP is a
13special type of [multi-window][2] mode mostly used for video playback.
14
15The app is *paused* when it enters PiP mode, but it should continue showing content. For this
16reason, you should make sure your app does not pause playback in its [onPause()][3]
17handler. Instead, you should pause video in [onStop()][4]. For more information, see [Multi-Window
18Lifecycle][5].
19
20To specify that your activity can use PIP mode, set `android:supportsPictureInPicture` to `true` in
21the manifest. (Beginning with the O Developer Preview, you do not need to set
22`android:resizeableActivity` to `true` if you are supporting PIP mode, either on Android TV or on
23other Android devices; you only need to `setrandroid:resizeableActivity` if your activity supports
24other multi-window modes.)
25
26You can pass a [PictureInPictureParams][6] to [enterPictureInPictureMode()][7] to specify how an
27activity should behave when it is in PiP mode. You can also use it to call
28[setPictureInPictureParams()][8] and update the current behavior. If the app is in not PiP mode, it
29will be used for later call of [enterPictureInPictureMode()][7].
30
31With a [PictureInPictureParams][6], you can specify aspect ratio of PiP activity and action items
32available for PiP mode. The aspect ratio is used when the activity is in PiP mode. The action items
33are used as menu items in PiP mode. You can use a [PendingIntent][9] to specify what to do when the
34item is selected.
35
36[1]: https://developer.android.com/guide/topics/ui/multi-window.html
37[2]: https://developer.android.com/guide/topics/ui/picture-in-picture.html
38[3]: https://developer.android.com/reference/android/app/Activity.html#onPause()
39[4]: https://developer.android.com/reference/android/app/Activity.html#onStop()
40[5]: https://developer.android.com/guide/topics/ui/multi-window.html#lifecycle
41[6]: https://developer.android.com/reference/android/app/PictureInPictureParams.html
42[7]: https://developer.android.com/reference/android/app/Activity.html#enterPictureInPictureMode(android.app.PictureInPictureParams)
43[8]: https://developer.android.com/reference/android/app/Activity.html#setPictureInPictureParams(android.app.PictureInPictureParams)
44[9]: https://developer.android.com/reference/android/app/PendingIntent.html
45
46Pre-requisites
47--------------
48
49- Android SDK 26
50- Android Build Tools v26.0.2
51- Android Support Repository
52
53Screenshots
54-------------
55
56<img src="screenshots/1-main.png" height="400" alt="Screenshot"/> <img src="screenshots/2-pip.png" height="400" alt="Screenshot"/>
57
58Getting Started
59---------------
60
61This sample uses the Gradle build system. To build this project, use the
62"gradlew build" command or use "Import Project" in Android Studio.
63
64Support
65-------
66
67- Google+ Community: https://plus.google.com/communities/105153134372062985968
68- Stack Overflow: http://stackoverflow.com/questions/tagged/android
69
70If you've found an error in this sample, please file an issue:
71https://github.com/googlesamples/android-PictureInPicture
72
73Patches are encouraged, and may be submitted by forking this project and
74submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
75
76License
77-------
78
79Copyright 2017 The Android Open Source Project, Inc.
80
81Licensed to the Apache Software Foundation (ASF) under one or more contributor
82license agreements.  See the NOTICE file distributed with this work for
83additional information regarding copyright ownership.  The ASF licenses this
84file to you under the Apache License, Version 2.0 (the "License"); you may not
85use this file except in compliance with the License.  You may obtain a copy of
86the License at
87
88http://www.apache.org/licenses/LICENSE-2.0
89
90Unless required by applicable law or agreed to in writing, software
91distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
92WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
93License for the specific language governing permissions and limitations under
94the License.
95