Opening multiple windows in android 6.0. Multi-window mode: an additional competitive advantage for Android applications


AT new version operating system Google has implemented very desired function- multi-window in Android Nougat. This feature allows you to run any application in windows, and not like Samsung and LG, which allow you to use multi-window only for some applications. It means that new feature 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 their time. Secondly, you cannot launch the same application in a new window. Luckily, there is a solution for the latter: an app called Parallel Windows for Nougat.

Before we walk you through how to use Parallel Windows, it's worth noting that this application is in alpha development and is experimental, so some bugs may occur. Keep this in mind when testing the application! Also, it goes without saying (but I'll say it anyway): you need to have Nougat to use this app.

So, now you can tell how to run multi-window 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 shown stating that the application is experimental. Click on the "I have read and understood" field, then click on "Continue".

On the next screen, you need to give two permissions to use all Parallel Windows features. 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 enabled, switch back to the Parallel Windows application.

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

Finally, you need to put "Hotspot Dimensions". This is where the Parallel Windows menu will be shown. By default, it's set to the middle right side of the screen, which is a great place to do so. I will be using this setting throughout the tutorial.

This completes the installation of Parallel Windows. Now you can use multi-window in Android Nougat.

How to use Parallel Windows

To start, swipe to the middle from the right side of the screen - the spot we talked about earlier when setting up "Hotspot Dimensions". The Parallel Windows menu opens.

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

The first option opens the application menu - it's quick and easy way open the 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.

The second icon launches the application in multi-window mode. The list will open recently open processes 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 may 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 that you need to select an application to get the mirror.

Anyone who has worked in multi-window mode on an Android device can confirm that this is very convenient in certain situations. Simple example: reading e-book with an electronic dictionary. Especially on a smartphone or tablet with a fairly large screen.
If a user has to choose between two applications that are similar in almost every way, but differ in support for simultaneous work with multiple windows, it is not surprising that he will choose one that 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.

Review

Working with multiple windows at the same time in Android is interesting feature, which is able to distinguish your application from many others, give it an additional competitive advantage. Many OEMs and ODMs such as Samsung, Ramos, and Huawei are subject to basic Android system finalization. In particular, they introduce 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.


Scenarios for using multi-window mode

Preliminary information

In June 2012, it was presented Cornerstone is 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 day, you can see the explosive growth of solutions to support 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 autumn 2015. Among other innovations, Android M Preview 2 is notable for the fact that it supports multi-window mode.


Development of Android Multitasking Solutions

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


Multi-window modes

In 2013, many solutions appeared on the market that are designed to work with multiple windows. They have been designed by OEMs and ODMs, independent vendors software and the open source community. In the table below, you can find a comparison of various Android multi-window technologies.

Product Cornerstone Standout Xposed Tieto
Description
Framework for organizing multitasking in Android OS
An open source library that can be used to build applications with floating windows
A multi-window application that supports docked windows
The project aims to create working environment, reminiscent of working on a desktop PC
Support for opening, closing windows, resizing, full screen
Yes
Yes
Yes
Yes
Window style
Pinned
floating
Pinned
Fixed and floating
Code modification
At the level Android platforms
At the application level
At the Android platform level
At the Android platform level
Application support
All applications are supported, however SurfaceView is not dynamically configured.
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
Cry
Cry
Cry
Cry

Software architecture

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

In the case of Android 4.2 and Android 4.3., the shell (launcher) and other applications are placed on the same stack when launched, called the "main stack" ("main stack"). As you know, multi-window mode requires more stacks to accommodate multiple windows. As a result, we need to modify the ActivityManagerService system class by adding an interface to it to create and manage the stack. To modify the WIndowManagerService platform class, which allows you to manage application graphical representations, you need to modify the InputManager. This is necessary so that it can redirect touch events to the appropriate windows.

FROM the release of Android 4.4 and Android 5.0, the stack management approach 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). The Android OS uses callback mechanisms to execute interface functions of an 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 an Activity in 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 you can start an Activity in this stack. In Lollipop, the following functions have been added to the IactivityManager.java interface:

After starting the SystemServer process, it calls the Activity manager services and windows ( windows manager services). In order to observe this process, we can add commands to throw a runtime exception (RuntimeException) in the appropriate places.


Stack creation process in Lollipop

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 central part of the window management system. Its functionality includes dispatching input events, managing 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, window resizing is available. There are examples when the size of the window that displays the 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 in multi-window mode are displayed incorrectly. In the figure below, you can see that the multi-window calculator is not displayed correctly. It's all about the layout of the application, which is not designed for such conditions of use.


Calculator with layout not designed to work in multi-window mode

Multi-window support in Android M

Android M Developer Preview 2 can be run on Nexus 5, 6, 9 and Nexus Player. If you don’t have such a device, or you don’t want to install an OS that is in Preview status on it, 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.

To see this mode in action, just create a new one. virtual device using the AVD Manager tool, while choosing one of the available ones with the Level MNC API as a system image. In our case, it was an x86_64 image. Next, you need to start the emulator, go to the settings section For the developer and enable the option there Multi-window mode. If you can't find this option, take a look at this guide

Now the most interesting. For starters, you can run a few applications, everything will be as usual. But if you click on the button to call the list recently open applications, in the titles of window thumbnails will appear new icon. By default, this is a frame indicating that the application is running in full screen mode. Clicking this icon will bring up a window layout selection menu.


Window layout selection menu in multi-window mode


Multi-window mode in Android M

Will multi-window operation be available in official release Android M is still unknown. 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 adapting applications for multi-window mode will turn from a competitive advantage into an urgent need.

If you want to equip your applications that are designed for more early versions Android, multi-window support, it's time to turn to solutions third party developers, which were discussed above. For example, to Cornerstone.

Example: Cornerstone

Onskreen created Cornerstone, the first multi-window framework for Android. It is designed for devices with big screens and tablets. The source code can be downloaded from Github. It supports working with Android versions 4.1 and 4.2. For more later versions this OS, Cornerstone has not yet been released. However, one can analyze source for Android 4.2 in order to find out technical details system operation.


Cornerstone's modifications Android Jelly Bean

Results

In many mobile devices ah, working under Android control OS used Intel processors®. How can developers improve the user experience of their applications? How to make applications more competitive? These questions lead us to continuously improve products on devices with Intel architecture Architecture (IA). Multi-window support is good example useful opportunity giving 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, watch a video and write a review to your friends about what they are watching. For example, to play a game and read its reviews. Today, multiple devices support multi-window operation. For example, these are Ramos i12, Teclast x98 and Cube i7 tablets, which runs Remix OS.


Multi-window mode on IA devices

Android N adds support for displaying multiple apps at the same time. On mobile devices, two applications can be launched side by side or on top of each other in mode split screen. On TVs, applications can use the "picture in picture" to play the video while users are working on another application.

If you are building an application using the N Preview SDK, you can specify how it will act in multi-window mode. For example, you can set the minimum allowable size for an application window. You can also disable multi-window mode for an application so that it only appears in full screen mode.

Review

On Android N, multiple apps can be on the screen at the same time. For example, the user can split the screen to browse the web page on the left and write a message Email on right. User experience varies by device.

  • On Android N mobile devices, split screen mode is available. In this mode, two applications are displayed side by side or on top of each other. The user can drag the split line to enlarge the window of one application and reduce the window of another.
  • On Android N Nexus Player for Apps will be available, which will allow the app to display content while the user is browsing or interacting with other apps.
  • Manufacturers of larger devices can enable freeform mode, where the user can resize each window in any way. In this case, in addition to the split screen mode, this mode will also be available on the device.

Rice. one. The two apps are displayed side by side in split screen mode.

The user can switch to multi-window mode in the following ways.

  • If the user opens and long-presses the name of an activity, it can be dragged to the selected part of the screen and switched to multi-window mode.
  • If the user long press the Browse button, the device will switch the current operation to multi-window mode and open overview screen, where the user can select a different operation to display together.

In this mode, only the last operation with which the user interacted is active at any given time. Such an operation is considered topmost. All other operations are suspended, even if they are displayed. However, the system gives suspended but visible operations higher priority than invisible ones. If the user interacts with one of the suspended activities, it is resumed and the previous top-most activity is suspended.

Note. In multi-window mode, the application can be suspended and still visible to the user. An application may need to continue its operations even if it is suspended. For example, a visible paused app that is playing a video will still show the video. That's why we not We recommend that you pause playback in the handlers of such applications. Instead, you should pause the video in and resume playback in .

If the user brings the application into multi-window mode, the system notifies the operation of the configuration change, as specified in the document. In fact, this change also affects life cycle operations, like notifying an application by the system when the device changes from portrait to landscape, only the screen sizes are changed, not the orientation. As described in the doc, the activity can handle the configuration change on its own, or it can let the system delete the activity window and recreate it with the new dimensions.

If the user enlarges one of the sides of the window, the system resizes the operation window according to the user's action and applies it as needed. If the application does not have time to draw new areas, the system temporarily fills them with color, given attribute or the default windowBackgroundFallback style attribute.

Configuring an application for multi-window mode

If your app is for Android N, you can specify how (and if) your app's operations support multi-window. The size and layout control attributes are set in the manifest. The attribute settings of a root activity apply to all activities in its task stack.

Note. If a multi-orientation app was created with an SDK earlier than Android N, and the user launches the app in multi-window mode, the system will force the app to resize. The system displays a warning dialog box that the application might work in an unexpected way. System not resizes the window for applications with a fixed orientation. If the user tries to open such an application in multi-window mode, it will take up the whole screen.

android:resizeableActivity

or manifest to enable or disable multi-window mode:

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

If this attribute is set to true, the activity can be run in split screen and freeform modes. If the attribute is set to false, the operation does not support multi-window mode. If the value is false and the user tries to run the activity in multi-window mode, the activity fills the entire screen.

If the app targets Android N, but no value has been specified for this attribute, the default value is true.

android:supportsPictureInPicture

Set this attribute on a node manifest to indicate whether the operation supports picture-in-picture mode. This attribute is ignored if android:resizeableActivity is set to false.

Android:supportsPictureInPicture=["true" | "false"]

Layout Attributes

In Android N manifest element supports several attributes that define the operation's behavior in multi-window mode.

Android:defaultWidth The default width of the activity window in freeform mode. android:defaultHeight The default height of the activity window in freeform mode. android:gravity The starting position of the activity window in freeform mode. See the class description for valid values. android:minimalSize The minimum height and width of the activity window in split screen and freeform modes. If the user moves the separator line in split screen mode to make the operation window smaller than the specified minimum, the system will crop it to the size requested by the user.

The following code example shows how to set the default size and position of the activity window, as well as its minimum size in freeform mode:

Launching an application in multi-window mode

Android N brings new features to support applications in multi-window mode.

Unavailable features in multi-window mode

Some features are disabled or ignored in multi-window mode because they do not make sense for an operation that is displayed on the device screen at the same time as other operations or applications. The following are examples of such possibilities.

  • Some customization options are disabled. For example, apps cannot hide the status bar unless they are running in full screen mode.
  • The system ignores attribute changes.

Change notifications and requests in multi-window mode

Activity.inMultiWindow() Call this method to find out if the activity is in multi-window mode. Activity.inPictureInPicture() Call this method to find out if the activity is in picture-in-picture mode.

Note. The picture-in-picture mode is a special case of the multi-window mode. If the myActivity.inPictureInPicture() method returns true, myActivity.inMultiWindow() also returns true.

Activity.onMultiWindowChanged() The system calls this method when the activity enters or exits multi-window mode. The system passes the method true if the operation enters multi-window mode and false if it exits it. Activity.onPictureInPictureChanged() The system calls this method when the activity enters picture-in-picture mode. The system passes the method true if the operation enters picture-in-picture mode and false if it exits.

Starting new operations in multi-window mode

When starting a new activity, you can tell the system to show the new activity window next to the current one, if possible. To do this, use the Intent.FLAG_ACTIVITY_LAUNCH_TO_ADJACENT flag. This flag requests the following behavior.

  • If the device is in split screen mode, the system tries to create a new activity window next to the one that launched it, to fit two activities on the screen. It is not guaranteed that the system will be able to do this, but if possible, the operations are displayed next to each other.
  • If the device is not in split screen mode, this flag is ignored.

If the device is in freeform mode when starting a new activity, you can set the size and position of the new activity's window by calling the ActivityOptions.setLaunchBounds() method. This method is ignored if the device is not in multi-window mode.

Note. If you run an activity on the task stack, it will replace the activity on the screen, inheriting all of its multi-window properties. To start a new activity in a separate window in multi-window mode, it must be started in a new task stack.

Drag and drop support

android.view.DropPermissions A token object for specifying permissions to the application into which the data is being dropped. View.startDragAndDrop() New alias for . To enable dragging between operations, pass the new View.DRAG_FLAG_GLOBAL flag. If you need to grant read or write URI permissions to the receiving operation, pass the new View.DRAG_FLAG_GLOBAL_URI_READ or View.DRAG_FLAG_GLOBAL_URI_WRITE flag respectively. View.cancelDragAndDrop() Cancels the current drag operation. This method can only be called by the application in which the drag operation was initiated. View.updateDragShadow() Replaces the shadow of the current drag operation. This method can only be called by the application in which the drag operation was initiated. Activity.requestDropPermissions() Requests permissions for the content URIs passed in the object in .

Testing the application in multi-window mode

Whether or not you update your app to Android N, you need to confirm its multi-window behavior in case the user tries to run it in multi-window mode on an Android N device.

Test device setup

If you install Android N on your device, split screen mode will be supported automatically.

If the application was created without using the N Preview SDK

If you did not use the N Preview SDK to create the application and the user tries to run it in multi-window mode, the system will force the application window to resize if its orientation is not fixed.

If the app is not set to a fixed orientation, you should launch it on an Android N device and try to put it in split screen mode. Make sure the app works fine after forced resizing.

If the application is set to a fixed orientation, try putting it in multi-window mode. Make sure the app stays in full screen mode while doing this.

If the application supports multi-window mode

If you used the N Preview SDK to build your app and didn't disable multi-window support, test your app in split-screen and freeform modes as described below.

  • Run the application in full screen mode, and then switch to multi-window mode by long pressing the "Browse" button. Make sure the application switches between modes correctly.
  • Run the application directly in multi-window mode and check that it works fine. You can launch an application in multi-window mode by pressing the Browse button, then long-pressing the application's title bar and dragging it to one of the highlighted areas on the screen.
  • Resize the app window in split screen mode by dragging the split line. Make sure resizing doesn't crash and that required UI elements remain visible.
  • If you have specified a minimum size for the application window, try setting it smaller than the minimum. Make sure you can't set the size below the specified minimum.
  • During all tests, monitor the performance of the application - it should be acceptable. For example, make sure that after resizing the application window, there is not a large delay in updating the interface.

Testing Checklist

To test the performance of an application in multi-window mode, perform the following operations. Try to run them in split-screen and multi-window mode unless otherwise noted.

  • Switch to multi-window mode and exit it.
  • Switch from your app to another app and check if the app works fine if it's visible but not active. For example, if an application is showing a video, it should continue to play while the user is working with another application.
  • In split screen mode, try moving the split line by making the application window larger and smaller. Try these operations when the windows of two applications are side by side and on top of each other. Make sure the app doesn't crash, the required elements are visible, and resizing doesn't take too long.
  • Quickly resize the application window several times in a row. Make sure the app doesn't freeze or leak memory. For information about checking application memory usage, see the document.
  • Play with the application in various window configurations and make sure it behaves as expected. The text should be easy to read and the interface elements should not be too small.

If you have disabled multi-window support

If you have disabled multi-window support by setting the android:resizableActivity="false" attribute, run the app on an Android N device and try to put it into freeform and split screen modes. Make sure the app stays in full screen mode while doing this.

The physical dimensions of the displays of modern mobile devices are becoming larger, while maintaining the convenience of working with them. Therefore, there is a problem of more rational use of space on the screen. Indeed, even in Android 6.0, they still did not dare to introduce the function of split-screen or windowed mode, although the capabilities of the system and the power of gadgets allow this. But when the producers have doubts, the community brings it to life.

Xposed Framework Activation

The second step is to install and activate a special module in Xposed called XHaloFloatingWindow. This can be done from the framework itself, but in this case the program we need will be in English, which is unacceptable given the abundance of settings and features.
Therefore, you can download the Russified XHaloFloatingWindow here:

The module is installed as a normal android application, but for proper operation it will be required to activate it and then reboot the device. To do this, go to Xposed on the "Installed modules" tab, find XHaloFloatingWindow in the list that appears, check the box and reboot in any convenient way.
Now we can move on to the program itself. You can launch it from the usual list of applications. The main screen is one of the settings tabs; at the initial stage, you only need to enable the "Windowed mode" item. Next, slide to the left to switch to the "Window Behavior" tab. In the "Launching Applications" category, tap on "White/Black List Options". In the menu that opens, select the second item.

That's all, now any programs will open as windows in any number that can be dragged, minimized or pinned to the top or bottom of the screen. Minimized windows will be available from the notification bar. Having studied the settings of XHaloFloatingWindow in more detail, the user can customize the behavior of applications completely to fit their needs, since the project allows this to be done in a wide range of ways.

XHaloFloatingWindow is currently in beta version, so there may be malfunctions, up to the inability to turn on the device.
In this case, do not panic, but do the following steps:

  1. Reboot your device again.
  2. Clear cache through recovery.
  3. Clear dalvik cache.
  4. Delete the /data/data/de.robv.android.xposed.installer/conf/modules.list file, you can do this either through ADB or through recovery.
  5. Remove Xposed using the appropriate archive.

After each item, you need to reboot the device, checking if the problem is fixed.

Hidden in Android 6.0 is an experimental option that allows you to use multi-window mode. Activating it is relatively difficult, but if you do everything right, there should not be any difficulties with this. Unlike a similar function on Samsung smartphones, 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 build, and not user. This can be done using a computer and custom recovery, and if the device is rooted, using a regular text editor.

First way

1. Install custom recovery on your 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 enter the recovery by pressing a certain key combination (usually the power button and the volume up and down buttons).

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

5. Connect your 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 the 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 typing the following command on the command line:

Adb push build.prop /system/

8. Enter three more commands that are needed in order to third party applications could not modify build.prop:

adb shell
cd system
chmod 644 build.prop

9. Reboot your smartphone and activate multi-window in the developer options.

Second way

On smartphones with root access, editing the build.prop file is much easier. It can be done special application Build Prop Editor or with text editor built into file manager like root explorer or X-Plore. The file is located at /system/build.prop, and in it 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 several 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 with a long press on the button home page(or at virtual button). You will see a new icon on the app page thumbnails. After clicking on it, the system will prompt you to choose the location of the application: on half, one-fourth of the screen or on the entire screen. When multiple applications are open, their window proportions can be changed.

Most likely in the future of Google will provide access to this android features to all users. Do you think smartphones and tablets need it or is it completely useless?







2022 gtavrl.ru.