diff --git a/docs/html/preview/features/multi-window.jd b/docs/html/preview/features/multi-window.jd new file mode 100644 index 0000000000000..6c5a5cb2aaf9b --- /dev/null +++ b/docs/html/preview/features/multi-window.jd @@ -0,0 +1,505 @@ +page.title=N Developer Preview Multi-Window Support +page.metaDescription=New support in the N Developer Preview for showing more than one app at a time. +page.keywords="multi-window", "android N", "split screen", "free-form" + +@jd:body + +
+ The N Developer Preview 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 you build your app with the N Preview SDK, you can configure how your app + handles multi-window display. For example, you can specify your activity's + minimum allowable dimensions, preventing users from making the activity + window smaller than that size. You can also disable multi-window display for + your app, ensuring that the system only shows your app in full-screen + mode. +
+ ++ The N Developer Preview 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: +
+ +
++ Figure 1. Two apps running side-by-side in split-screen mode. +
+ ++ The user can switch into multi-window mode in the following ways: +
+ ++ 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. +
+ ++ 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. 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 resizes a window and makes it larger in either dimension,
+ the system fills in the expanded
+ area with the color specified by the {@link android.R.attr#windowBackground
+ windowBackground} attribute, or by the default
+ windowBackgroundFallback style attribute. When the user finishes
+ resizing the window, the activity is redrawn with its new dimensions, as
+ described in Handling Runtime
+ Changes.
+
+ If your app targets the N Developer Preview, 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. +
+ ++ Note: If you build a multi-orientation app with a version of the + SDK earlier than the N Developer Preview, 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. +
+ +
+ Set this attribute in your manifest's <activity> or
+ <application> node to enable or disable multi-window
+ display:
+
+android:resizableActivity=["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 the N Developer Preview, but you do not specify a value + for this attribute, the attribute's value defaults to true. +
+ +
+ Set this attribute in your manifest's <activity> node to
+ indicate whether the activity supports picture-in-picture display.
+
+android:supportsPictureInPicture=["true" | "false"] ++ +
+ With the N Developer Preview, the <layout> manifest element
+ supports several attributes that affect how an activity behaves in
+ multi-window mode:
+
android:defaultWidth
+ android:defaultHeight
+ android:gravity
+ android:minimalSize
+ + 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:minimalSize="450dp" /> +</activity> ++ +
+ The N Developer Preview offers new 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: + +
android:screenOrientation attribute.
+ + The following new methods have been added to the {@link android.app.Activity} + class to support multi-window display. For details on each method, see the + + N Preview SDK Reference. +
+ +Activity.inMultiWindow()
+ Activity.inPictureInPicture()
+
+ Note: Picture-in-Picture mode is a special case of
+ multi-window mode. If myActivity.inPictureInPicture()
+ returns true, then myActivity.inMultiWindow() also returns
+ true.
+
Activity.onMultiWindowChanged()
+ Activity.onPictureInPictureChanged()
+
+ There are also {@link android.app.Fragment} versions of each of these
+ methods, for example Fragment.inMultiWindow().
+
+ To put an activity in picture-in-picture mode, call the new method
+ Activity.enterPictureInPicture(). This method has no effect if
+ the device does not support picture-in-picture mode. For more information,
+ see
+ Picture-in-Picture Mode.
+
+ 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 flag
+ Intent.FLAG_ACTIVITY_LAUNCH_TO_ADJACENT. Passing
+ 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. +
+ ++ Whether or not you update your app for the N Developer Preview, you should + verify how it behaves in multi-window mode in case a user tries to launch it + in multiwindow mode on a device running the N Developer Preview. +
+ ++ If you install the N Developer Preview on a device, split-screen mode is + automatically supported. +
+ ++ If you did not build your app with the N Preview SDK 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 the N Developer Preview 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 you built your app with the N Preview SDK and have not disabled + 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 the N Developer Preview 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.
+