The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.
In 2017, Samsung released the Galaxy S8 and S8+. They also released the Samsung DeX, a docking station for the S8/S8+ that not only provides power, an Ethernet jack, and USB ports, but it also has an HDMI port.
Figure 1093: Samsung DeX, Front Top Showing Device Connector
Figure 1094: Samsung DeX, Rear Showing Ports
not only can that HDMI port be used the way it is on many other
Android devices (screen mirroring,
Presentation, etc.), but also in a
“DeX” mode that simulates a freeform multiwindow experience. In this
mode, the touchscreen is turned off, and the user navigates the windows
using a keyboard and mouse (USB or Bluetooth), as with a traditional
Figure 1095: DeX Mode, Showing Freeform-Style Windows
On the whole, developers do not seem to be concerning themselves too much with DeX — for example, as of mid-June 2017, there was exactly one question on Stack Overflow related to DeX. That being said, the DeX is an interesting demonstration of where Android 7.0’s multi-window modes will head. Plus, it is yet another environment that puts keyboards and mice “front and center” for users and, by extension, app developers.
The user has two choices when docking their device in the DeX: screen mirroring mode and DeX mode.
What Samsung describes as “screen mirroring” mode is pretty much what you would
expect from an Android device connected to an HDMI display. By default,
the contents of the touchscreen are mirrored on the HDMI display. And, if you
use things like
Presentation, you can display separate content
on the HDMI display from what is shown on the touchscreen.
However, this mode may not be very popular, for one simple reason: the device
is docked in the DeX in portrait mode. This means that the content shown on the
HDMI device, by default, is in portrait mode. While you could lock your activity
to landscape mode, so its
Presentation appears in landscape, then the activity
is in the wrong orientation on the touchscreen.
More often than not, if people are bothering to put their devices in a DeX, it is to use Dex mode, with freeform-style windows.
This chapter refers to these windows as “freeform-style”, as while the S8 and S8+ shipped with Android 7.0, they do not appear to have the freeform setting enabled. Hence, Samsung “rolled their own” freeform multiwindow implementation, and the developer (and user) experience in DeX mode will differ somewhat from what “official” freeform multiwindow mode is like.
Activities that are not resizeable will appear in portrait mode by default:
Figure 1096: Non-Resizeable Activity on DeX in Portrait
There is an icon in the title bar that allows the user to rotate the window to landscape:
Figure 1097: Non-Resizeable Activity on DeX in Landscape
Activities that are resizeable — the
android:resizeableActivity="true" — can be resized by using a mouse and
dragging the window edges, as with a traditional desktop operating system.
All windows, resizeable or not, can be minimized or maximized. Maximized windows will fill the screen.
The preview of this section was accidentally identified as an Android 'tasty treat' by the Cookie Monster.
The preview of this section is [REDACTED].