Tech tip of this week

Multi Window Support in Android N

Android N 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.
In below picture, you can see two apps running side by side.







Multi-window mode does not change the activity life cycle.

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 onPause() handlers. Instead, they should pause video in onStop(), and resume playback in onStart().

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.

API:

  • android:resizeableActivity=["true" | "false"] 
  • android:supportsPictureInPicture=["true" | "false"] 
  • Activity.isInMultiWindowMode() 
  • Activity.isInPictureInPictureMode() 
  • Activity.onMultiWindowModeChanged() 
  • Activity.onPictureInPictureModeChanged() 
  • Intent.FLAG_ACTIVITY_LAUNCH_TO_ADJACENT 
  • ActivityOptions.setLaunchBounds() 
  • Layout attributes

Below is the behavior when app is in multi window mode.

1) When Device is in Portrait mode: Even if the device is in portrait, your app might be in ‘landscape’ orientation.

2) When Device is in Landscape mode: Even if the device is in landscape, your app might be in ‘portrait’ orientation.

How to implement:
By default, Multi window feature will be enabled for all the apps for Android N. You can disable/enable multi window feature with below property.

Set this attribute in your manifest's <activity> or <application> node to enable or disable multi-window display:

android:resizeableActivity=["true" | "false"]

Test:
Open the application and go to overview screen(recent screen) long press on the app and drag to highlighted area.

No comments:

Post a Comment