What Android 11 Offers
Android 11 adds SurfaceControlViewHost
. The name is awkward, but the capability it enables is enticing. Simply put, a SurfaceControlViewHost
allows one app to have a view hierarchy (e.g., an inflated layout) be displayed in another app.
The approach taken by RemoteViews
and slices is to send a description of a UI between processes, with the recipient being responsible for rendering the UI. By contrast, SurfaceControlViewHost
works by sharing a Surface
between the two apps, by means of the SurfaceControl
class added in Android 10. The app with the view hierarchy renders to the Surface
through the SurfaceControlViewHost
, while the recipient renders the Surface
itself through a SurfaceView
.
Now the app with the view hierarchy has much greater control over what the result looks like. Any desired widgets, styles, and themes are available, because there is no requirement that the recipient have access to any of those things — all the recipient is doing is displaying the shared Surface
.
The biggest limitation is that SurfaceControlViewHost
is new to Android 11, as is the ability to connect the shared Surface
to a SurfaceView
. It may be possible to backport this to Android 10, when SurfaceControl
was introduced, but that is far from certain. Since it takes years for users to get new versions of Android (usually via replacing their devices), this means that this capability, while interesting, will have limited real-world applicability for a while.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.