Multi-window mode: an additional competitive advantage for Android applications

Original author: Liang Li
  • Transfer
Everyone who worked in multi-window mode on an Android device can confirm that in certain situations it is very convenient. A simple example: reading an e-book with an electronic dictionary. Especially - on a smartphone or tablet with a fairly large screen.
If the user has to choose between two applications that are similar in almost everything, but differ in support for simultaneous work with multiple windows, it is not surprising that he will choose what provides such support. From the article you will learn about multi-window mode in Android, and how to use this feature when building your own applications.


Simultaneous work with multiple windows in Android is an interesting feature that can distinguish your application from many others, give it an additional competitive advantage. Many OEMs and ODMs, such as Samsung, Ramos, and Huawei, are modifying the base Android system. In particular, they are introducing multi-window support. They do this in order to increase the attractiveness of their smartphones and tablets, to distinguish them from the bulk of devices that do not support such a function.

Scenarios for using multi-window mode

Preliminary information

In June 2012, Cornerstone was introduced - the first open source platform for multitasking on Android. In August 2012, Samsung released the first device that supports multi-window operation. From 2013 to the present, you can observe the explosive growth of solutions to support the simultaneous work with multiple windows in Android.

In May 2015, Android M Developer Preview was released (today, in July, Preview 2 is already available). The official release of Android M (6.0) is expected in the fall of 2015. Among other innovations, Android M Preview 2 is noteworthy in that it supports multi-window mode.

Developing multitasking solutions in Android

There are two approaches to working with multiple windows: this is the use of floating (floating) and docked (docked) windows. Among the main possibilities of working in multi-window modes, one can note opening and closing windows (open / close), changing their size (resize) and relative position (swap). Opening or closing a window, we respectively enable or disable multi-window mode. The resize function allows you to adjust the size of the windows. Repositioning windows is an action that allows you to swap them.

Multiple Window Modes

In 2013, the market appeared a lot of solutions designed to work with multiple windows. They were developed by OEMs and ODMs, independent software vendors, and the open source community. In the table below you can find a comparison of various technologies for organizing multi-window work in the Android environment.
Android multitasking framework
An open source library that can be used to create floating window applications.
A multi-window application that supports docked windows
The project aims to create a desktop environment resembling work on a desktop PC
Support for opening, closing windows, resizing, expanding to full screen
Window style
Docked and floating
Code modification
Android platform level
Application level
Android platform level
Android platform level
Application support
All applications are supported, however, SurfaceView dynamic configuration is not available.
Some supporting applications. For example, a calculator.
The compatibility and stability of the solution needs to be improved.
Supports all applications.
Android version
Android 4.1. - Android 4.4.
Android 4.1. - Android 4.4.
Android 4.4.
Android 4.4
Official site

Software architecture

Android platform code can be modified in order to equip it with support for additional features. Android OS architecture consists of several levels.

In the case of Android 4.2 and Android 4.3., The shell (launcher) and other applications are placed on the same stack at launch, called the “main stack”. As you know, multi-window mode requires more stacks to accommodate multiple windows. As a result, you need to modify the system class ActivityManagerService, adding an interface to it for creating and managing the stack. To modify the platform class WIndowManagerService, which allows you to manage graphical representations of applications, you need to change the InputManager. This is necessary so that he can redirect touch events to the corresponding windows.

With the release of Android 4.4 and Android 5.0, the approach to managing the stack has changed significantly. The shell and other applications can run on various stacks. Support for multiple stacks and the ability to manage them have been added to the system. The figure below shows the differences in working with the stack in different versions of Android.

Comparison of the work with the stack in Android 4.3 and Android 4.4

Now we will focus on Android 5 (Lollipop). Android OS uses callback mechanisms to perform the interface functions of Activity. However, the control function is implemented at the platform level. Therefore, now we will consider two important classes: ActivityManagerService and WindowManagerService.

Lollipop Platform Software Structure

Managing Activity at Lollipop

Since the ability to work in multi-window mode depends on the stack, the following shows how you can create a stack and how to start Activity in this stack. In Lollipop, the following functions have been added to the interface:
New features of the interfaceDescription
public void moveTaskToStack (int taskId, int stackId, boolean toTop)Move task to another stack
public void resizeStack (int stackBoxId, Rect bounds)
Resize Stack
public void setFocusedStack (int stackId)
Set focus to the selected task
Public Boolean isInHomeStack (int taskId)
Find out if a task is in HomeStack

After starting, the SystemServer process calls the activity management services and windows management services. In order to observe this process, we can add runtime exceptions (RuntimeException) to the appropriate places in the command.

The process of creating a stack in Lollipop

Now let's see how to start an Activity on the stack:

Starting an Activity on a stack

In Lollipop, the following commands were added to the ADB utility (Android Debug Bridge, Android debug bridge):
ADB team
Adb shell am stack start
Launches a new Activity on using intent
In Kitkat 4.4, ADB commands contain: adb shell am stack create
In Lollipop 5.0: adb shell am stack create deletion
Adb shell am stack movetask
Moves from the current stack up or down the stack
Usage: adb shell am stack movetask task_id stackid true / false
Note: this works in Kitkat, but not in Lollipop
Adb shell am stack resize
Resize stack and his position on
Usage: adb shell am stack resize task_id weight

Window Management in Lollipop

WindowManagerService is the central part of the window management system. Its functionality includes scheduling input events, controlling the location of objects on the screen and the surfaces on which graphic elements are displayed.

Role of WindowsManagerService in Android Graphics Architecture

Multi Window Issues

When working in multi-window mode, resizing windows is available. Examples are known where the size of the window displaying the game animation cannot be resized. The main reason for this is that the Android SurfaceFlinger subsystem cannot dynamically change the size of the output image.

Games that use SurfaceFlinger cannot dynamically change the window size.

Another problem is that some applications do not display correctly in multi-window mode. In the figure below you can see that the calculator does not display correctly in multi-window mode. It's all about the layout of the application, which is not designed for such conditions of use.

Calculator with a layout not designed for multi-window operation

Support for multi-mode in Android M

Android M Developer Preview 2 can be launched on Nexus 5, 6, 9 and Nexus Player. If you don’t have such a device, or if you don’t want to install an OS in it in Preview status, you can get acquainted with Android M using the emulator in Android Studio. In particular, now we are interested in standard tools for working in multi-window mode.

In order to see this mode in action, it is enough to create a new virtual device using the AVD Manager tool, while choosing as a system image one of the ones available with the API Level MNC. In our case, it was an x86_64 image. Next, you need to run the emulator, go to the settings section for the developer and enable the Multi-window mode option there. If this option cannot be found, take a look at this guide.

Now the fun part. For starters, you can run several applications, everything will be as usual. But if you click on the button for calling up the list of recently opened applications, a new icon will appear in the headers of the window thumbnails. By default, this is a frame that indicates that the application is starting in full screen mode. If you click on this icon, a menu for selecting the layout of the window layout appears.

The menu for choosing the layout of the location of windows in multi-window mode

Then everything is completely clear. Select the desired layout and enjoy the multi-window mode:

Multi-window mode in Android M

It is still unknown whether multi-window operation will be available in the official release of Android M. However, for example, the system calculator in this mode feels good. As a result, we have good reason to believe that the day is not far off when the adaptation of applications for multi-window mode from a competitive advantage will turn into an urgent need.

If you want to equip your applications designed for earlier versions of Android with support for multiple windows, it's time to turn to the solutions of third-party developers, which were discussed above. For example, to Cornerstone.

Example: Cornerstone

Onskreen created Cornerstone, the first framework to work with multiple windows on Android. It is designed for devices with large screens and tablets. Source code can be downloaded on Github . It supports working with Android versions 4.1 and 4.2. For later versions of this OS, Cornerstone has not yet been released. However, you can analyze the source code for Android 4.2 in order to find out the technical details of the system.

Cornerstone Mods on Android Jelly Bean


Many mobile devices running Android OS use Intel® processors. How can developers improve the user experience of working with their applications? How to make applications more competitive? These questions lead us to continually improve products on devices with Intel Architecture (IA). Multi-window support is a good example of a useful feature that gives applications a competitive edge. This is convenient, multi-window mode gives the user the ability to perform several tasks simultaneously. For example, to watch a video and write a review to friends about what they’re watching. For example, play a game and read its reviews. Today, multiple devices support multi-window operation. For example, these are the Ramos i12, Teclast x98, and Cube i7 tablets,

Multi-window mode on IA devices

For home reading

» Android 6.0 Muffin Concept Video Shows Multi-Windows, Quick Reply Feats

Thank you for your attention!

Also popular now: