Illustration by Ocupop

The L in 12L

Pietro Maggi
Android Developers
Published in
3 min readApr 7, 2022

--

It’s no secret that the L in 12L stands for large screens.

There are a lot of large screen devices, including tablets and foldables, that run Android applications. Then we have even larger screen devices that run Android applications even if their native OS is something else, like Chrome OS.

12L adds new features to improve the user’s experience on a large screen device. One of these improvements is the simpler UI to enter split-screen multi window mode (split-screen mode in the rest of the article):

12L’s recents screen showing Split control

Note: Split-screen mode is a special case of multi-window mode. In split-screen mode, two apps are displayed side by side on screen. See Multi-window support.

In this article we will cover a feature that makes it easier to build a multi-window experience for large screen users.

If your application needs to open some other content through an intent, you can use the FLAG_ACTIVITY_LAUNCH_ADJACENT to open it in a new adjacent window.

This flag was introduced in Android 7.0 to allow an application to target the intent to an adjacent window when the device is already in split-screen mode.

What’s new in 12L is that the flag now allows an application to enter split-screen mode.

Note: OEMs can enable the 12L behavior on older Android versions. For example, Samsung enabled this behavior on Android 11+ devices as did Microsoft on the Surface Duo.

You can see this behavior with a recent version of the Chrome browser running on 12L if the device’s minimum screen size is above 600dp. A long press on a link will show a contextual menu with the option to open the link in a new window:

Chrome’s menu option to open link in a new window on screens larger than 600dp

If you try the same on a compact screen (as defined by the new window size classes), the option is not there:

Chrome’s menu option on screens smaller than 600dp

If you instead open the context menu while the device is already in split-screen mode, you will get the option to open the link in the other window:

Chrome’s menu option to open link in other window when already in split-screen mode

Show me the code

The core of this is to use FLAG_ACTIVITY_LAUNCH_ADJACENT when launching the second activity:

What we can also do is to add FLAG_ACTIVITY_LAUNCH_ADJACENT if the device is already in split-screen mode (see Activity#isInMultiWindowMode()) or if the device has a large screen:

We can use the WindowMetricsCalculator from Jetpack WindowManager to decide if we are above the 600dp viewport breakpoint:

Activity embedding

FLAG_ACTIVITY_LAUNCH_ADJACENT is great for scenarios where you just want to open a new window to show a web page or some other content in another application or in another activity in your own application. It’s a fire and forget scenario.

If you need more control on how the new activity should look or you require greater control over the integrations of the two activities in your application, take a look at Activity embedding, another 12L feature exposed through an experimental API in Jetpack WindowManager 1.0.

Embrace split-screen mode in your application

Google is investing a lot of resources to improve the user experience on large screen devices. The Android 12L feature drop is a testament to this and users are adopting these devices that allow longer and more complex interactions.

Now it’s a great time to improve your application support for split-screen mode.

--

--