
Posted by Alex Vanyo, Developer Relations Engineer
At Google I/O we introduced that Pixel Pill and Pixel Fold are becoming a member of our Pixel household of units. With pre-orders ongoing, now could be the time to replace your purposes to work nice on these units!
This weblog covers two subjects: what makes Pixel Fold and Pixel Pill distinctive, and how one can check your app on these units earlier than they’re typically accessible.
The excellent news about Pixel Fold and Pixel Pill is that, in case your app is already optimized for bigger screens, you gained’t have a lot to do.
For normal giant display screen developer steering, begin with developer.android.com/large-screens. Moreover, we printed a weblog submit proper earlier than I/O with some widespread do’s and don’ts for big screens. And we printed a entire set of movies at I/O for easy methods to optimize your apps for big screens.
Moreover the final giant display screen growth steering, there are some things that make Pixel Fold and Pixel Pill distinctive out there immediately:
- Pixel Fold unfolds from portrait to panorama (not portrait to portrait)
- Pixel Fold rear digital camera sensor orientation is orthogonal to the internal show orientation
- Pixel Pill has a dock
We’ll undergo every of those individually so you already know what to look out for when updating your individual apps.
Present a pleasant unfold expertise
Probably the most frequent app points we encountered in the course of the growth of Pixel Fold is apps that don’t account for dynamically going from a portrait to panorama show setting. On Pixel Fold and Pixel Pill, the consumer can rotate and fold their machine as they select, and multitask with any app. If an app restricts orientation or resizability, the system locations the app right into a compatibility mode when the consumer is utilizing the app in a configuration the app doesn’t help straight. Previous assumptions made in your app, like assuming that the app is operating fullscreen and it gained’t be resized, may cause points with these new units.
There are two courses of issues apps expertise when a consumer is unfolding a tool:
When you don’t handle and save UI states correctly, your consumer can lose state when going from the folded outer show to the unfolded internal show. This may be extraordinarily irritating for customers. For instance, a consumer would possibly start filling out a type in an app in a small window in multi-window mode or on the outer show of a foldable and notice the additional display screen space of a bigger window or display screen could be useful for finishing the duty. In case your app loses state, the consumer loses all earlier type entry information and is compelled to start out throughout. Whereas this isn’t distinctive to Pixel Fold (the identical bugs would doubtless happen in case your app had been resized in multi-window mode), the state of affairs turns into much more widespread on a foldable when the act of going from folded to unfolded is a typical prevalence.
The takeaway: be sure to’re saving UI state correctly.
One other concern we see is apps being letterboxed on the internal show, even when they help a panorama structure. We’ve additionally seen instances the place apps could be letterboxed on the Pixel Fold internal show when the machine is held within the pure panorama orientation, however rotating the machine to portrait and again to panorama could make the apps return to full display screen!
All of those bugs originate from “isTablet” boolean logic.
Let’s assume we’re engaged on an app that makes use of “isTablet” logic to find out if the exercise orientation must be restricted to portrait. We see a variety of builders do that to limit their structure to portrait on telephones, however unlock panorama help on giant display screen units. A standard option to decide isTablet is to make use of a smallest-width certified boolean worth (for instance, isTablet=true for sw>=600dp) or equal code utilizing the WindowMetricsCalculator computeCurrentWindowMetrics APIs.
Let’s stroll this logic by the situation of a consumer doing the next steps with Pixel Fold:
- Open the app on the outer show
- With the app nonetheless open, unfold the machine
- Rotate the unfolded machine to portrait
- Rotate the machine again to panorama
Step 1: Open the app on the outer show
On this case, the smallest-width worth is < 600dp and stories isTablet=false. The app restricts the exercise’s orientation to portrait and the app gained’t rotate to panorama on the outer show.
Step 2: Unfold the machine
Step 3: Rotate the unfolded machine to portrait
When the consumer rotates the internal show to portrait, the appliance can reap the benefits of the complete show for the reason that exercise’s orientation and the show orientation match. On this case, the smallest width is > 600 dp and isTablet evaluates to true. When you have software logic to cease proscribing the exercise orientation based mostly on these standards, your exercise will not be portrait however will as an alternative change into unspecified.
Step 4: Rotate again to panorama
Now once you rotate to panorama, the appliance takes benefit of your complete display screen, and there shall be no letterboxing. Whereas that is the specified end result, the steps to get there could be extraordinarily complicated for a consumer! Customers gained’t perceive why your software is full display screen panorama in some instances however not others.
There are two methods to repair this:
- Cease proscribing exercise orientation
- Use the Jetpack WindowMetricsCalculator computeMaximumWindowMetrics API to find out the utmost dimension your window may very well be on the present show.
We strongly suggest the primary means. In case your software is purposeful and usable in panorama on a standard cellphone show, we encourage you to not limit the app to portrait in any state of affairs. Android has an auto-rotation lock characteristic (and Pixel Fold allows customers to specify this setting independently for the outer and internal show), so let the customers resolve in the event that they need to all the time use their outer show in portrait or not.
In case your app has evident usability or purposeful points on a panorama, conventional phone-size show, then use the WindowMetricsCalculator computeMaximumWindowMetrics API to retrieve the utmost dimension your app’s window may very well be if resized. We’ve got a cookbook recipe for this particular use case. Nonetheless, this must be a brief resolution till you make your panorama structure work in all places.
Make your digital camera preview work for all states
Digital camera preview is a fancy subject that’s relevant provided that your software makes use of the digital camera straight, so we’ll simply spotlight the issue and make a fast advice. For extra superior makes use of of Android digital camera, see the in-depth Digital camera preview information.
Advice: Until you might have superior Digital camera API necessities, use the CameraX library, which incorporates easy-to-use APIs that keep away from most of the digital camera preview orientation issues described under.
Drawback: That is associated to the structure concern. As a result of the outer and internal shows of some foldables have completely different pure orientations, it may well’t be true that each shows match the rear digital camera sensor orientation. So, one of many shows must be orthogonal to the digital camera sensor. For Pixel Fold, this implies the internal show pure orientation of panorama is rotated relative to the primary digital camera sensor’s pure orientation of portrait.

This will trigger problem when constructing digital camera preview shows if in case you have beforehand assumed that the digital camera orientation all the time matches your UI orientation. You have to be sure to’re dealing with rotation logic for the shows and sensor correctly so that you don’t get a distorted, rotated, or cropped digital camera preview. If you’re additionally proscribing orientation and your app is letterboxed, the orientation of your app might not match the orientation of the machine or the orientation of the digital camera.
There’s a variety of depth to this subject, however the Digital camera preview information will enable you get by this step-by-step.
Deal with the Pixel Pill dock
Final however not least is the Pixel Pill charging speaker dock.Outputting sound to the dock is rather like outputting to the exterior audio system, and apps shouldn’t actually need to do something to replace for the dock out of the field.

Docking and undocking triggers a uiMode configuration change.
Make sure that your app works as anticipated when going from docked to undocked and again.Most apps already deal with this gracefully.
This might occur if you’re doing one thing in your software’s onConfigurationChanged handlers that might trigger a disruptive expertise when a tool is docked or not. For instance, in case your software consists of a component that’s taking part in media or different content material, don’t pause playback when onConfigurationChanged known as. Many apps already deal with this nicely and there’s not a lot to contemplate. This shall be a nuisance to customers who could also be watching a video on the dock after which need to take it on the go, or who begin taking part in music whereas holding the pill after which dock it to make use of the dock’s higher audio system.
When you’ve up to date your software to work nice on giant display screen units, you possibly can check them within the new Pixel Fold and Pixel Pill configurations in Android Studio Hedgehog Canary 3 or later. These emulators are nice for testing structure, however we’re persevering with to enhance these emulators to serve extra options sooner or later.

To check digital camera preview orientation flexibility, we suggest making an attempt any pill together with your digital camera preview in multi-window mode and constantly resizing your software window to ensure your digital camera preview works as anticipated.
Now’s the time to replace your purposes in order that they delight customers who start unboxing their Pixel Fold and Pixel Pill units later this month!