How to make multi-window mode on android 5.1. Multi-window mode: An additional competitive advantage for Android apps. Managing Activity in Lollipop

IN new version operating room google systems implemented very desired function- multiple windows in Android Nougat... This feature allows you to run any application in windows, and not like Samsung and LG, which only allow you to use multiple windows for some applications. It means that new function works for almost all applications, all the time.

However, there are limitations. First, the feature probably won't work with legacy apps that haven't been updated in due time. Secondly, you cannot launch the same application in a new window. Fortunately, there is a solution for the latter: an application called Parallel Windows for Nougat.

Before we talk about how to use Parallel Windows, it is worth noting that this application is in Alpha Development and is experimental, so some bugs may occur. Keep this in mind when testing your application! Also, it goes without saying (but I'll say it anyway): you need to have Nougat in order to use this app.

So, now we can tell you how to start multi-windowing in Android Nougat. First, install Parallel Windows (it's free). After installation, launch the application.

How to install Parallel Windows

After launching the application, a warning will be displayed indicating that the application is experimental. Click on the "I have read and understood" box, then click on "Continue".

On the next screen, you need to give two permissions in order to take advantage of all the features of Parallel Windows. Click on the first switch "Permit to draw over Apps", you will be taken to the permission menu, where you need to enable it. Once you enable the permission, go back to the Parallel Windows app.

Next, in the main menu, click on the "Enable Accessibility Service" switch. You will be taken to the accessibility menu, where you will need to enable Parallel Windows for Nougat. A pop-up window will appear, in which it will be said what the application will have access to, click "OK". Again, just press the back button to return to the main application.

Finally, you need to put "Hotspot Dimensions". This is where the Parallel Windows menu will appear. By default, it is set in the middle of the right side of the screen, which is a great place to do this. I will use this parameter throughout the tutorial.

This completes the installation of Parallel Windows. You can now use multiple windows in Android Nougat.

How to use Parallel Windows

First, swipe to the middle of the right side of the screen - in the place we talked about earlier when setting up "Hotspot Dimensions". The Parallel Windows menu will open.

There are three options here, from top to bottom: open the applications menu, launch a multi-window session, and an application mirror.

The first option opens the Applications Menu - a quick and easy way to open an application. Selecting an application from the application menu will automatically open the application in multi-window mode. It is also worth noting that it will take time to display all installed applications if there are many of them.

The second icon launches the application in multi-window mode. A list of recently opened processes will open and you need to select the application you are interested in at the bottom of the window.

The second option can be used without using Parallel Windows. The third option is the most powerful, it allows you to use the application mirror in multi-window mode. However, it can seem confusing.

To use this feature, you must first run at least one application in windowed mode. Open the Parallel Windows menu and select the bottom option. A pop-up message will appear telling you to Select an application to get a mirror.

Attention! The article uses screenshots and options from the Android 7.1 operating system. Although most of the described elements should be present in other versions of Android, the author does not guarantee this.

How to activate developer options

Despite the fact that the article will focus on the settings for developers, you should not be intimidated by this name. Some of the options presented in this section will come in handy and ordinary users... By default, they don't appear in the settings, but it's easy to fix.

  1. Open up Android settings and go to the "About phone" section.
  2. Scroll to the bottom. Find the line "Build number".
  3. Make seven quick taps in a row on this element. As a result, a notification should be displayed that you have now become a developer, and the corresponding section will appear in the settings menu.

Now let's take a look at some of the possibilities that have opened up to us.

Some developers specifically disable the ability to install to an SD card in their applications. Using the "Allow saving to external drives" switch, you can enable this regardless of the developer's wishes.

Please note that the developer may have a good reason to prohibit installation on an external card. Some programs are hard-coded to a specific location and will not work if they are not installed where the developer intended. Therefore, use this function with caution.

Multi-window mode is the thing latest versions operating systems from Google... However, for this function to work, not only the correct version of Android is required, but also support in the applications themselves, which, unfortunately, not all developers have taken care of.

With the help of the option "Resize in multi-window mode" you can use any application in this mode.

Usually smartphones turn off the screen themselves during inactivity to conserve battery power. However, in some cases this feature is not needed. For example, if you want to use old smartphone as a table clock or in a car as a navigator.

The option "Do not turn off the screen" will allow the smartphone to stay in active mode all the time while it is connected to the charger.

This is one of the most useful options for achieving significant visual acceleration. Android work... The fact is that some producers in pursuit of wow effects overload too much operating system beautiful animation.

In this section of options for the developer, you can independently set the time they are displayed or disable them altogether. As a result, it will seem that the system just started to fly.

If your device uses an AMOLED screen, then the number of colors displayed really matters to save battery. To stretch even more on the remaining charge, simply activate monochrome mode. This option is also hidden in the developer settings and is called "Simulate anomaly".

And what useful options for developers are you using?

Hidden away in Android 6.0 is an experimental option that allows you to use multi-window mode. It is relatively difficult to activate it, but if you do everything correctly, there should be no difficulties with this. Unlike a similar function on smartphones Samsung, it works with all applications.

In order for the multi-window option to appear on Android 6.0, you just need to edit the build.prop file, indicating that you are using the userdebug assembly, and not the user. This can be done using a computer and custom recovery, and if root access is obtained on the device, using a regular text editor.

The first way

1. Install custom recovery on the device (for example, TWRP). To do this, download and install ADB from the Android SDK. Then download the recovery image for your device, rename it to twrp.img and place the ADB folder.

2. Connect your smartphone to your computer with a USB cable, open a command prompt and run three commands:

Adb reboot bootloader
fastboot flash recovery twrp.img
fastboot reboot

3. Turn off your smartphone and go into recovery by pressing a certain key combination (usually the power button and volume up and down buttons).

4. In the recovery, select the Mounts section and put a cross in front of System.

5. Connect the smartphone to the computer with a cable and on the computer in command line issue the following command:

Adb pull /system/build.prop

6. The build.prop file will be downloaded to your computer. Open it in notepad and replace the line "ro.build.type = user" with "ro.build.type = userdebug"



7. Download the build.prop file back to your smartphone by entering the command in the command line:

Adb push build.prop / system /

8. Enter three more commands that are needed in order to third party applications couldn't modify build.prop:

Adb shell
cd system
chmod 644 build.prop

9. Restart your smartphone and enable multi-window in developer settings.

Second way

On rooted smartphones, editing the build.prop file is much easier. It can be done special application Build Prop Editor or using text editor embedded in file manager like Root Explorer or X-Plore. The file is located at /system/build.prop and you need to replace the line “ro.build.type = user” with “ro.build.type = userdebug”.

How to activate multi-window?

1. Open in system settings, go to the "About device" section and tap the Android build number a few times.

2. A section for developers will appear in the settings. Go into it - you will see a switch that allows you to activate multi-window.

3. Open the multitasking screen by long pressing the button home page(or on a virtual button). You will see a new icon on the app page thumbnails. After clicking on it, the system will offer you to choose the location of the application: on half, one-fourth of the screen or on the whole screen. When multiple applications are open, the aspect ratio of their windows can be changed.

Most likely in the future of google will open access to this Android functions to all users. Do you think smartphones and tablets need it or is it completely useless?

Anyone who has worked in multi-window mode on an Android device can attest that it is very convenient in certain situations. A simple example: reading e-book with an electronic dictionary. Especially - on a smartphone or tablet with a large enough screen.
If a 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.

In this article, you will learn about multi-window mode in Android, and how to use this feature when building your own applications.

Overview

Simultaneous work with multiple windows in Android is interesting function, which is able to distinguish your application from many others, to give it an additional competitive advantage. Many OEMs and ODMs such as Samsung, Ramos and Huawei are subject to basic system Android revision. In particular, they are introducing support for multi-window mode. 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.


Multi-window usage scenarios

Preliminary information

In June 2012, the Cornerstone Is the first open source platform for multitasking on Android. In August 2012, Samsung released the first multi-window device. From 2013 to the present day, you can see an explosive growth in solutions to support simultaneous work with multiple windows in Android.

In May 2015, the 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 notable for the fact that it supports multi-window mode.


Development of solutions to support multitasking in Android

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


Multiple Window Modes

In 2013, many solutions appeared on the market, designed to work with multiple windows. They were developed by OEMs and ODMs, ISVs, and the open source community. In the table below you can find a comparison of different technologies for organizing multi-window work in the Android environment.

Product Cornerstone Standout Xposed Tieto
Description
A framework for organizing multitasking work in Android OS
An open source library that can be used to create floating window applications
Multi-window application that supports docked windows
The project aims to create a desktop-like work environment
Support for opening, closing windows, resizing, expanding to full screen
Yes
Yes
Yes
Yes
Window style
Anchored
Floating
Anchored
Docked and floating
Code modification
Android platform level
At the application level
Android platform level
Android platform level
Application support
All applications are supported, however dynamic configuration of SurfaceView is not available.
Some helper 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
Cry
Cry
Cry
Cry

Software architecture

Android platform code can be modified to support it additional opportunities... The Android OS architecture consists of several layers.

In the case of Android 4.2 and Android 4.3, the launcher and other applications are placed on a single stack when launched, 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 ActivityManagerService system class by adding an interface to it for creating and managing a stack. To modify the platform class WIndowManagerService, which allows you to manage the graphical views of applications, you need to modify the InputManager. This is necessary so that it can forward touch events to the appropriate windows.

With the release of Android 4.4 and Android 5.0, the approach to stack management has changed significantly. The shell and other applications can run on different 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 Android.


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

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


Lollipop platform software structure

Managing Activity in Lollipop

Since the ability to work in multi-window mode depends on the stack, below shows how you can create a stack and how you can start an Activity on that stack. Lollipop adds the following functionality to the IactivityManager.java interface:

Once started, the SystemServer process calls the activity manager services and windows management services. In order to observe this process, we can add in the appropriate places the commands to throw a runtime exception (RuntimeException).


Lollipop stack creation process

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


Launching an Activity on the stack

In Lollipop, the following commands have been added to the ADB (Android Debug Bridge) utility:

Window management in Lollipop

WindowManagerService is the heart of the windowing system. Its functionality includes dispatching input events, managing the position of objects on the screen, and the surfaces on which graphical elements are displayed.


Role of WindowsManagerService in Android graphics architecture

Multi-window problems

When working in multi-window mode, resizing of windows is available. There are known examples when the size of the window displaying game animation cannot be changed. The main reason for this is that the Android SurfaceFlinger subsystem cannot dynamically resize the rendered image.


Games using SurfaceFlinger cannot dynamically resize the window

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


Calculator with non-multi-window layout

Multi-window support in Android M

Android M Developer Preview 2 can be run on Nexus 5, 6, 9 and Nexus Player. If similar device you do not have, or you do not want to install an OS on it that is in the Preview status, you can get acquainted with Android M using the emulator in Android Studio. In particular, we are now interested in standard means to work 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 selecting one of the available with API Level MNC as a system image. In our case, it was an x86_64 image. Next, you need to start the emulator, go to the For developer settings section and enable the Multi-window mode option there. If you can't find this option, take a look at this guide.

Now comes the fun part. To begin with, you can run several applications, everything will be as usual. But if you click on the button to call the list recently open applications, a new icon appears in the window thumbnail headers. By default, this is a border indicating that the application is launched in full screen mode... If you click on this icon, the window layout selection menu will appear.


Window layout selection menu in multi-window mode


Multi-window mode in Android M

Whether it will be available to work with multiple windows in the official release of Android M is still unknown. However, for example, the system calculator feels good in this mode. 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 will turn from a competitive advantage into an urgent need.

If you want to equip your applications with more early versions Android, with support for multiple windows, it's time to turn to the third-party solutions mentioned above. For example, to Cornerstone.

Example: Cornerstone

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


Cornerstone mods in Android Jelly Bean

Outcomes

In many mobile devices working under Android OS used Intel processors®. How can developers improve the user experience of their applications? How to make apps more competitive? These questions lead us to continually improve products on Intel Architecture (IA) devices. Support for working in multi-window mode is good example a useful feature that gives applications a competitive advantage. This is convenient, multi-window mode gives the user the ability to perform several tasks at the same time. For example - watching a video and writing a review to your friends about what you are watching. For example, playing a game and reading reviews. Today, multiple devices support multi-window operation. For example, these are Ramos i12, Teclast x98 and Cube i7 tablets, which are running Remix OS.


Multi-window mode on IA devices

We translate ... Translate Simplified Chinese Traditional Chinese English French German Italian Portuguese Russian Spanish Turkish

Unfortunately, we cannot translate this information right now - please try again later.

Overview

Simultaneous work with multiple windows in Android is an interesting feature that can distinguish your application from many others and give it an additional competitive edge. Many OEMs and ODMs, such as Samsung, Ramos, and Huawei, subject the base Android system revision. In particular, they are introducing support for multi-window mode. 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.

Picture 1. Multi-window usage scenarios

Preliminary information

In June 2012, the Cornerstone Is the first open source platform for multitasking on Android. In August 2012, Samsung released the first multi-window device. From 2013 to the present day, you can see an explosive growth in solutions to support simultaneous work with multiple windows in Android.

In May 2015, the 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 notable for the fact that it supports multi-window mode.

Figure 2. Development of solutions to support multitasking in Android

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

Figure 3.Multi-window window styles

In 2013, many solutions appeared on the market, designed to work with multiple windows. They were developed by OEMs and ODMs, ISVs, and the open source community. In the table below you can find a comparison of different technologies for organizing multi-window work in the Android environment.

ProductCornerstone Standout Xposed Tieto
DescriptionA framework for organizing multitasking work in Android OSAn open source library that can be used to create floating window applicationsMulti-window application that supports docked windowsThe project aims to create a desktop-like work environment
Support for opening, closing windows, resizing, expanding to full screenYesYesYesYes
Window styleAnchoredFloatingAnchoredDocked and floating
Code modificationAndroid platform levelAt the application levelAndroid platform levelAndroid platform level
Application supportAll applications are supported, however dynamic configuration of SurfaceView is not available.Some helper applications. For example, a calculator.The compatibility and stability of the solution needs to be improved.Supports all applications.
Android versionAndroid 4.1 ~ Android 4.4Android 4.1 ~
Android 4.4
Android 4.4Android 4.4
Official sitehttp://www.onskreen.comhttp://forum.xda-developers.com/showthread.php?t=1688531http://forum.xda-developers.com/xposedhttps://github.com/tieto/multiwindow_for_android

Software architecture

The Android platform code can be modified to support additional features. The Android OS architecture consists of several layers.

In the case of Android 4.2 and Android 4.3, the launcher and other applications are placed on a single stack when launched, 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 ActivityManagerService system class by adding an interface to it for creating and managing a stack. To modify the platform class WIndowManagerService, which allows you to manage the graphical views of applications, you need to modify the InputManager. This is necessary so that it can forward touch events to the appropriate windows.

With the release of Android 4.4 and Android 5.0, the approach to stack management has changed significantly. The shell and other applications can run on different 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.

Figure 4. Comparison of working with the stack in Android 4.3 and Android 4.4

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

Figure 5. Lollipop platform software structure

Managing Activity in Lollipop

Since the ability to work in multi-window mode depends on the stack, below shows how you can create a stack and how you can start an Activity on that stack. Lollipop adds the following functionality to the IactivityManager.java interface:

Once started, the SystemServer process calls the activity manager services and windows management services. In order to observe this process, we can add in the appropriate places the commands to throw a runtime exception (RuntimeException).

Figure 6. Lollipop stack creation process

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

Figure 7. Launching an Activity on the stack

In Lollipop, adb (android debug bridge) added the following commands.

In Lollipop, the following commands have been added to the ADB (Android Debug Bridge) utility:

Window management in Lollipop

WindowManagerService is the heart of the windowing system. Its functionality includes dispatching input events, managing the position of objects on the screen, and the surfaces on which graphical elements are displayed.

Figure 8. Role of WindowsManagerService in Android Graphics Architecture

Multi-window problems

When working in multi-window mode, resizing of windows is available. There are known examples when the size of the window displaying game animation cannot be changed. The main reason for this is that the Android SurfaceFlinger subsystem cannot dynamically resize the rendered image.

Figure 9. Games using SurfaceFlinger cannot dynamically resize the window

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

Figure 10.Calculator with non-multi-window layout

Multi-window support in Android M

Android M Developer Preview 2 can be run on Nexus 5, 6, 9 and Nexus Player. If you do not have such a device, or you do not want to install an OS on it that is in the Preview status, you can get acquainted with Android M using the emulator in Android Studio. In particular, we are now 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 selecting one of the available with API Level MNC as a system image. In our case, it was an x86_64 image. Next, you need to start the emulator, go to the For developer settings section and enable the Multi-window mode option there. If you can't find this option, take a look at this guide.

Now comes the fun part. To begin with, you can run several applications, everything will be as usual. But if you click on the button to call the list of recently opened applications, a new icon will appear in the headers of the window thumbnails. By default, this is a border indicating that the application is running in full screen mode. If you click on this icon, the window layout selection menu will appear.

Figure 11.Multi-window mode in Android M

Whether it will be available to work with multiple windows in the official release of Android M is still unknown. However, for example, the system calculator feels good in this mode. 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 will turn from a competitive advantage into an urgent need.

If you want to equip your earlier Android apps with multi-window support, it's time to turn to the third-party solutions discussed above. For example, to Cornerstone.

Example: Cornerstone

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

Figure 12. Cornerstone mods in Android Jelly Bean

Outcomes

Many mobile devices running Android OS use Intel® processors. How can developers improve the user experience of their applications? How to make apps more competitive? These questions lead us to continually improve products on Intel Architecture (IA) devices. 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 at the same time. For example - watching a video and writing a review to your friends about what you are watching. For example, playing a game and reading reviews. Today, multiple devices support multi-window operation. For example, these are Ramos i12, Teclast x98 and Cube i7 tablets, which are running Remix OS.

Figure 13.Multi-window mode on IA devices