Android MultiWindow Support

Gonza F Picó
AndroidPub
Published in
3 min readJan 30, 2017

Have you seen the new feature that Android N brings? Do you know that you can share your screen between two apps? Did you know that your current app can split? In this article I’ll show you how to make an Android app that has Multiwindow support.

First of all, you need to know that if you want to do it in your app your app should must target API 24 (Android 7.0) or higher. The user experience depends on the device. On TV devices, apps can put themselves in picture-in-picture mode. It allows them to keep showing content while the user browses or interacts with other apps.

The multiwindow lifecycle is the same that the activity lifecycle. You could have two apps in the top sharing the screen. Both of them will be visible. But one of them is paused although visible. This is the one that is not focused. Then, as tip, you should make the behavior on onStop() instead of onPause(). For instance, if the user is playing a video, stop it during onStop() and not onPause(). So, the user could have two apps running at the same time. As soon as the user goes back to your app, you should handle runtime changes. Otherwise, Android will refresh all the screen.

To configure your app to multiwindow mode is very easy. There are two attributes:

1.- ANDROID:RESIZEABLEACTIVITY

It should be true.

2.- ANDROID:SUPPORTSPICTUREINPICTURE

It should be true. If android:resizeableActivity is false, it doesn’t matter what this property is. It has low weight than the first one.

#AndroidDev
Keep an eye to android:resizeableActivity and android:supportsPictureInPicture in Android Multiwindow
Support

Besides there are layout attributes affected where an activity behaves in multi-window mode. You can see in action in this snippet:

Running the app in multiwindow mode has the next functionalities:

  • Disabled features in multi-window mode
  • Multi-window change notification and querying
  1. isInMultiWindowMode()
  2. isInPictureInPictureMode()

If myActivity.isInPictureInPictureMode() returns true, then myActivity.isInMultiWindowMode() also returns true.

The system calls this method when the activity goes in or out of picture-in-picture mode

The system calls this method whenever the activity goes into or out of picture-in-picture mode

  • Entering picture-in-picture mode

Call Activity.enterPictureInPictureMode()

  • Launch New Activities in Multi-Window Mode

use the intent flag FLAG_ACTIVITY_LAUNCH_ADJACENT

So, how many of you do you have an app target of API 24? Are you think it to update it to add this new functionality? The first time I listened to this, I didn’t like too much, but I used in the Google Apps of my Nexus 5x and it’s very interesting. I hope you find this article helpful!

Thank you for your time reading this article. If you found it helpful, do not hesitase to click the ❤ below and share it.

--

--

Gonza F Picó
AndroidPub

Working on AppDermis | #Freelance in mobile industry | #Entrepreneur newbie | #GIG | ‘The more I learn, the more I realize how much I don’t know’