With Android Q, Google is continuing its work on expanding Android beyond the traditional smartphone, tablet, smartwatch, and television form factors. The Samsung Galaxy Fold and Huawei Mate X foldable smartphones have drawn most of our attention toward Android Q’s native support for the foldable form factor, but Google is quietly asking developers to rework their apps to support another multi-display scenario: desktops and monitors.

Huawei and Samsung have led the charge in bridging the gap between the smartphone and desktop PC with the introduction of Easy Projection and DeX respectively. As is tradition, Google is taking the best parts of OEM software and slowly incorporating them into AOSP. In Android Q, the company is adding native support for a “desktop mode.” You wouldn’t know it, however, since the company never mentioned it during any of their Google I/O keynotes, instead relegating it to a small part of a session on building apps for foldables and multi-display form factors (AKA desktop mode).

In the talk titled "Build Apps for Foldable, Multi-Display, and Large-Screen Devices," Andrii Kulian, Software Engineer on the Android Framework WindowManager Team working on Multi-Display, shared details on how developers can prepare their apps for multi-display environments.

"Foldable phones may have several screens, but you can also find multi-display in cars, in phones connected to larger screens in desktop mode, in Chrome OS, and so on." - Andrii Kulian, Google.

Developing for the new Desktop Mode in Android Q

If you're interested in updating your Android app to support desktop environments, you should watch the session embedded at the end of this article. I'll summarize the key points, though:

  • In order for your app to support simultaneous use on the primary (phone) and secondary (monitor) screens, your app must support multiple instances. With the intent flags NEW_TASK and MULTIPLE_TASK, Android Q can create a second window of your app on the secondary display.
    Android Q multi-resume desktop mode
  • The new multi-resume behavior also applies to multi-display scenarios. Thus, you can configure your app to run while another app has focus.
  • If you think your app should launch primarily on the primary or secondary display, you can check flags, metrics, and the state to find the right display to launch the activity on. Note that the system may restrict activity launches on private displays for which Google added a new API in Android Q to check if the caller can launch an activity on a specific activity.
  • Google has added support in Android Q for showing the software keyboard window on the secondary screen. Although it's still possible to only have one software keyboard window at a time, the window can move between the displays.
    Android Q desktop mode
  • Wallpapers and live wallpapers can be separate on multi-displays.
    Android Q desktop mode wallpapers
  • As shown in the feature image, the desktop mode has support for third-party launchers on secondary screens. Google has added a new category to the intent filter to provide a dedicated activity for secondary screens. The activity must have a launch mode that doesn't prevent multiple instances and that adapts to different screen sizes. The user can set the launcher of their choice on the device, and if the currently chosen launcher has a dedicated activity for secondary screens, it will be put there by the system.
  • Developers can test their apps on secondary screens by enabling the "force desktop mode," which turns on system declarations on all supported screens and shows the mouse pointer there instead of the current display, and "enable freeform windows" to allow floating app windows. You'll need to reboot the device for the changes to take effect, however. If you own a Google Pixel, you can try desktop mode by enabling a simulated display in Developer Options. On other devices with support for display out over HDMI, you can try desktop mode if you have a USB-C to HDMI adapter. The Essential Phone, for example, starts the new desktop mode in Android Q simply by plugging it into a monitor.

I'm taking a wild guess here, but I think the upcoming Pixel 4 will support display out over HDMI so Google can tout Android Q's new desktop mode as a feature. We'll find out in 5 months when Google launches the new Pixels.

Thanks to XDA Senior Member farmerbb for the heads up about the talk!