Posted by Francesco Romano – Developer Relations Engineer on Android
App display screen sharing improves privateness and productiveness
Android 14 QPR2 brings thrilling developments in person privateness and streamlined multitasking with app display screen sharing. Now not do customers should broadcast their whole display screen whereas display screen sharing or casting, guaranteeing they share precisely what they wish to share.
Leverage the brand new MediaProjection APIs to customise the display screen sharing expertise and ship even higher utility to your customers.
What’s app display screen sharing?
Previous to Android 14, customers might solely share or document their whole display screen on Android gadgets, which might expose personal data in different apps or notifications.
App display screen sharing is a brand new platform function that lets customers limit sharing and recording to a single app window, mitigating the danger of oversharing personal messages or notifications. With app display screen sharing, the standing bar, navigation bar, notifications, and different system UI components are excluded from the shared show. Solely the content material of the chosen app is shared.
This not solely enhances safety for display screen sharing, but additionally allows new use instances on massive screens. Customers can enhance multitasking productiveness – similar to display screen sharing whereas attending a gathering – by benefiting from further display screen area on these bigger gadgets.
How does it work?
There are three completely different entry factors for customers to start out app display screen sharing:
- Begin casting from Fast Settings
- Begin display screen recording from Fast Settings
- Launch from an app with display screen sharing or recording capabilities by way of the MediaProjection API
Let’s take into account an instance the place a bunch person needs to share a single app to the contributors of a video name.
The host person begins display screen sharing as regular, however now in Android 14 they’re introduced with an up to date dialog that enables them to decide on whether or not to share a single app as a substitute of their whole display screen.
The host person decides to share a single app, and so they choose the app from the App Selector.
Throughout display screen sharing, the video name contributors can see solely the content material from the chosen app.
The host person can finish the display screen seize in a couple of methods: from the app the place sharing began, within the notification shade, by closing the app being shared, or by ending the video name.
Methods to help app display screen sharing?
Apps that use the MediaProjection APIs are able to beginning app display screen sharing with none code modifications. Nevertheless, it’s necessary to check your app to make sure that the display screen sharing expertise works as supposed, for the reason that person circulation modifications with this new habits. Beforehand, the person would keep within the host app after the permission dialog. With app display screen sharing the person just isn’t returned to the host app, however the goal app to be shared is launched as a substitute. If the goal app was already operating in foreground (e.g. in multi window mode), then it merely turns into the highest centered app.
Android 14 additionally introduces two callback strategies to empower you to customise the sharing expertise:
MediaProjection.Callback#onCapturedContentResize(width, top) is invoked instantly after seize begins or when the scale of the captured area modifications. The strategy arguments present the correct sizing for the streamed seize.
Word: The given width and top correspond to the identical width and top that might be returned from android.view.WindowMetrics#getBounds() of the captured area.
If the recorded content material has a unique facet ratio from both the VirtualDisplay or output Floor, the captured stream has black bars across the recorded content material. The applying can keep away from the black bars across the recorded content material by updating the scale of each the VirtualDisplay and output Floor:
override enjoyable onCapturedContentResize(width: Int, top: Int): String { // VirtualDisplay occasion from MediaProjection#createVirtualDisplay(). virtualDisplay.resize(width, top, dpi) // Create a brand new Floor with the up to date measurement. val textureName: Int // the OpenGL texture object identify val surfaceTexture = SurfaceTexture(textureName) surfaceTexture.setDefaultBufferSize(width, top) val floor = Floor(surfaceTexture) // Make sure the VirtualDisplay has the up to date Floor to ship the seize to. virtualDisplay.setSurface(floor) }
The opposite API is MediaProjection.Callback#onCapturedContentVisibilityChanged(isVisible), which is invoked after seize begins or when the visibility of the captured area modifications. The strategy argument signifies the present visibility of the captured area.
The callback is triggered when:
- The captured area turns into invisible (isVisible==False).This will likely occur when the projected app just isn’t topmost anymore, like when one other app solely covers it, or the person navigates away from the captured app.
- The captured area turns into seen once more (isVisible==True).This will likely occur if the person strikes the protecting app to point out a minimum of some portion of the captured app (for instance, the person has a number of apps seen in multi-window mode).
Purposes can reap the benefits of this callback by exhibiting or hiding the captured content material from the output Floor primarily based on whether or not the captured area is at present seen to the person. It is best to pause or resume the sharing accordingly with a purpose to preserve sources.
How Google Meet is enhancing assembly productiveness
“App display screen sharing allows customers to share particular data in a Meet name with out oversharing personal data on the display screen like messages and notifications. Customers can select particular apps to share, or they can share the entire display screen as earlier than. Moreover, customers can leverage split-screen mode on massive display screen gadgets to share content material whereas nonetheless seeing the faces of buddies, households, coworkers, and different assembly contributors.” – Product Supervisor at Google Meet
Let’s see app display screen sharing in motion throughout a video name, on this coming-soon model of Google Meet!
Window on the world
App display screen sharing opens doorways (and home windows) for extra centered and safe app experiences inside the Android ecosystem.
This new function enhances a number of use instances:
- Collaboration apps can facilitate centered dialogue on particular design components, paperwork, or spreadsheets with out together with distracting background particulars.
- Tech help brokers can remotely view the person’s downside app with out seeing probably delicate content material in different areas.
- Video conferencing instruments can share a presentation window selectively moderately than your complete display screen.
- Academic apps can exhibit performance with out compromising scholar privateness, and college students can share tasks with out concern of exhibiting delicate data.
By thoughtfully implementing app display screen sharing, you’ll be able to set up your app as a champion of person privateness and comfort.
Leave a Comment