Android 7.0 adds support for displaying more than one app at the same time. On handheld devices, two apps can run side-by-side or one-above-the-other in split-screen mode. On TV devices, apps can use picture-in-picture mode to continue video playback while users are interacting with another app.
If your app targets Android 7.0 (API level 24) or higher, you can configure how your app handles multi-window display. For example, you can specify your activity's minimum allowable dimensions. You can also disable multi-window display for your app, ensuring that the system only shows your app in full-screen mode.
Android 7.0 allows several apps to share the screen at once. For example, a user could split the screen, viewing a web page on the left side while composing an email on the right side. The user experience depends on the device:
The user can switch into multi-window mode in the following ways:
Users can drag and drop data from one activity to another while the activities are sharing the screen.
Multi-window mode does not change the activity lifecycle.
In multi-window mode, only the activity the user has most recently interacted with is active at a given time. This activity is considered topmost. All other activities are in the paused state, even if they are visible. However, the system gives these paused-but-visible activities higher priority than activities that are not visible. If the user interacts with one of the paused activities, that activity is resumed, and the previously topmost activity is paused.
Note: In multi-window mode, an app can be in the paused
state and still be visible to the user. An app might need to continue its
activities even while paused. For example, a video-playing app that is in
paused mode but is visible should continue showing its video. For this
reason, we recommend that activities that play video not pause the
video in their
Instead, they should pause video in
onStop(), and resume playback in
When the user puts an app into multi-window mode, the system notifies the activity of a configuration change, as specified in Handling Runtime Changes. This also happens when the user resizes the app, or puts the app back into full-screen mode. Essentially, this change has the same activity-lifecycle implications as when the system notifies the app that the device has switched from portrait to landscape mode, except that the device dimensions are changed instead of just being swapped. As discussed in Handling Runtime Changes, your activity can handle the configuration change itself, or it can allow the system to destroy the activity and recreate it with the new dimensions.
If the user is resizing a window and makes it larger in either dimension, the
system resizes the activity to match the user action and issues runtime changes
as needed. If the app lags behind in drawing in newly-exposed areas, the
system temporarily fills those areas with the color specified by the
windowBackground attribute or by the default
windowBackgroundFallback style attribute.
If your app targets API level 24 or higher, you can configure how and
whether your app's activities support multi-window display. You can set
attributes in your manifest to control both size and layout.
A root activity's attribute settings apply to all activities
within its task stack. For example, if the root activity has
android:resizeableActivity set to true, then all activities
in the task stack are resizeable.
Note: If you build a multi-orientation app that targets API level 23 or lower, and the user uses the app in multi-window mode, the system forcibly resizes the app. The system presents a dialog box warning the user that the app may behave unexpectedly. The system does not resize fixed-orientation apps; if the user attempts to open a fixed-orientation app under multi-window mode, the app takes over the whole screen.
android:resizeableActivity=["true" | "false"]
If this attribute is set to true, the activity can be launched in split-screen and freeform modes. If the attribute is set to false, the activity does not support multi-window mode. If this value is false, and the user attempts to launch the activity in multi-window mode, the activity takes over the full screen.
If your app targets API level 24, but you do not specify a value for this attribute, the attribute's value defaults to true.
android:supportsPictureInPicture=["true" | "false"]
With Android 7.0, the
<layout> manifest element
supports several attributes that affect how an activity behaves in
Gravityreference for suitable values.
For example, the following code shows how to specify an activity's default size and location, and its minimum size, when the activity is displayed in freeform mode:
<activity android:name=".MyActivity"> <layout android:defaultHeight="500dp" android:defaultWidth="600dp" android:gravity="top|end" android:minHeight="450dp" android:minWidth="300dp" /> </activity>
Beginning with Android 7.0, the system offers functionality to support apps that can run in multi-window mode.
Certain features are disabled or ignored when a device is in multi-window mode, because they don’t make sense for an activity which may be sharing the device screen with other activities or apps. Such features include:
Activity offers the following methods to support
Note: Picture-in-picture mode is a special case of
multi-window mode. If
returns true, then
To put an activity in picture-in-picture mode, call
Activity.enterPictureInPictureMode(). This method has no effect if the
device does not support picture-in-picture mode. For more information, see
When you launch a new activity, you can hint to the system that the new
activity should be displayed adjacent to the current one, if possible. To do
this, use the intent flag
this flag requests the following behavior:
If a device is in freeform mode and you are launching a new activity, you can
specify the new activity's dimensions and screen location by calling
ActivityOptions.setLaunchBounds(). This method has no effect if
the device is not in multi-window mode.
Note: If you launch an activity within a task stack, the activity replaces the activity on the screen, inheriting all of its multi-window properties. If you want to launch the new activity as a separate window in multi-window mode, you must launch it in a new task stack.
Users can drag and drop data from one activity to another while the two activities are sharing the screen. (Prior to Android 7.0, users could only drag and drop data within a single activity.) For this reason, you may want to add drag and drop functionality to your app if your app does not currently support it.
View.startDrag(). To enable cross-activity drag and drop, pass the flag
DRAG_FLAG_GLOBAL. If you need to give URI permissions to the recipient activity, pass the flags
DRAG_FLAG_GLOBAL_URI_WRITE, as appropriate.
ClipDatacontained in a
Whether or not your app targets API level 24 or higher, you should verify how it behaves in multi-window mode in case a user tries to launch it in multi-window mode on a device running Android 7.0 or higher.
If a device runs Android 7.0 or higher, it automatically supports split-screen mode.
If your app targets API level 23 or lower and the user attempts to use the app in multi-window mode, the system forcibly resizes the app unless the app declares a fixed orientation.
If your app does not declare a fixed orientation, you should launch your app on a device running Android 7.0 or higher and attempt to put the app in split-screen mode. Verify that the user experience is acceptable when the app is forcibly resized.
If the app declares a fixed orientation, you should attempt to put the app in multi-window mode. Verify that when you do so, the app remains in full-screen mode.
If your app targets API level 24 or higher and does not disable multi-window support, verify the following behavior under both split-screen and freeform modes.
To verify your app's performance in multi-window mode, try the following operations. You should try these operations in both split-screen and multi-window mode, except where otherwise noted.
If you disabled multi-window support by setting
android:resizableActivity="false", you should launch your app on
a device running Android 7.0 or higher and attempt to put the app in
freeform and split-screen modes. Verify that when you do so, the app remains
in full-screen mode.