Optimizing Android Apps for Multi-Window Mode

Avatar

James

One of my favorite features in Android 7.0 Nougat is support for multiple applications running at the same time with the new Multi-Window mode. When the user has an application open and long presses on the app switcher button, they can select a second application to put side by side, which opens up new scenarios, such as dragging and dropping content. On tablets and other larger devices, this also enables a new freeform mode that allows applications to be fully re-sized. Out of the box applications should be able to take advantage of this new mode, as Android Activities will automatically re-size to the correct proportions when the app enters this mode. Here are two Xamarin.Android applications in the new Multi-Windows mode, one built with Xamarin.Forms and the other built with traditional Xamarin.Android.

f3399082-eeef-432f-b9e4-3a6bb4f344df

As you can see, out of the box Multi-Window mode should be supported in your app, however, there are a lot of other optimizations that you can add that will delight your users.

Application Configuration

There are a few easy settings to enable and disable Multi-Window mode for your entire application for a single Activity when you compile against API 24.

If you’re using a sub-classed Application, you can add the ResizeableActivity attribute:

If this is set to true, the activity and application can be launched into split-screen and freeform modes. If you specify this on a single Activity and the user navigates to it, then the new activity will go back into full screen mode. If you’re targeting API 24 and don’t set this attribute, the default will be true.

Launching Activities Side-by-Side

Another neat feature is the ability to launch side-by-side if the user is already in a split-screen session by adding a few flags to your intent before starting the new Activity:

8d34720d-75c9-4ecb-9d6f-a753b5a42a07

Activity Configuration

Starting with Android 7.0, there’s a new Layout attribute that you can add to any Activity class that specifies additional parameters when the Activity is in Multi-Window mode. Here’s an example of specifying location along with the minimum and default dimensions when the Activity is launched into freeform mode:

Detecting Multi-Window Mode

Sometimes you may want to enable or disable parts of your user interface or functionality when the user enters Multi-Window mode. You can easily detect the new IsInMultiWindowMode boolean on any Activity.

Additionally, you can be notified when the user enters or exits Multi-Window mode by overriding the OnMultiWindowModeChanged method:

Learn More

When optimizing for Multi-Window mode, there are a few other considerations to keep in mind, such as supporting drag and drop and all of the different types of configurations that users may attempt to launch your app in. Be sure to read through the official Android documentation on Multi-Window mode for a full testing check-list.

Avatar
James Montemagno

Principal Program Manager, Mobile Developers Tools

Follow James   

No Comments.