World wide Event and Technology related Blog

Responsive Ads Here

Picture-in-Picture mode

         Picture-in-picture in Android 8.0.
Android 8.0 (API level 26) allows activities to launch inpicture-in-picture (PIP) mode. PIP is a special type of multi-window mode mostly used for video playback. PIP mode was originally available for Android TV only; Android 8.0 makes the feature available on other Android devices.
When an activity is in PIP mode, it is in the paused state, but should continue showing content. For this reason, you should make sure your app does not pause playback in its onPause() handler. Instead, you should pause video in onStop(), and resume playback in onStart(). For more information, see Multi-Window Lifecycle.
To specify that your activity can use PIP mode, setandroid:supportsPictureInPicture to true in the manifest. (Beginning with Android 8.0, PIP does not require the android:resizeableActivity manifest attribute. However, you must setandroid:resizeableActivity to `true` if your activity supports other multi-window modes.)
Android 8.0 (API level 26) introduces a new object, PictureInPictureParams, which you pass to PIP methods to specify how an activity should behave when it is in PIP mode. This object specifies properties such as the activity's preferred aspect ratio.
The existing PIP methods described in Adding Picture-in-picture can now be used on all Android devices, not just on Android TV. In addition, Android 8.0 provides the following methods to support PIP mode:
  • Activity.enterPictureInPictureMode(PictureInPictureParams args): Places the activity in picture-in-picture mode. The activity's aspect ratio and other configuration settings are specified by args. If any fields in args are empty, the system uses the values set the last time you called Activity.setPictureInPictureParams().
    The specified activity is placed in a corner of the screen; the rest of the screen is filled with the previous activity that was on screen. The activity entering PIP mode goes into the paused state, but remains started. If the user taps the PIP activity, the system shows a menu for the user to interact with; no touch events reach the activity while it is in the PIP state.
  • Activity.setPictureInPictureParams(): Updates an activity's PIP configuration settings. If the activity is currently in PIP mode, the settings are updated; this is useful if activity's aspect ratio changes. If the activity is not in PIP mode, these configuration settings are used regardless of the enterPictureInPictureMode() method that you call.

No comments:

Post a Comment