Posted by Alex Vanyo, Developer Relations Engineer
With the rise in Android apps getting used on massive display type components like foldables and tablets, increasingly apps are constructing totally adaptive UIs. See Assist totally different display sizes for finest practices for updating your app for finest practices for updating your app. The underside line is that Format and app habits ought to be primarily based on gadget configuration and out there options, and never the bodily sort of the gadget.
On the similar time, we get this query rather a lot: “Is there a straightforward strategy to inform if a tool is a foldable, pill, or one thing else?”
It might sound that utilizing the bodily sort of gadget gives all the data builders have to create nice experiences. Nevertheless, we are able to make extra adaptive apps with a greater person expertise by including extra context. For instance:
- Would you like “flip”-style telephones to rely as foldables?
- Do you need to decide if a tool is a pill, or simply if mobile performance is obtainable?
- What would rollables rely as? What about ChromeOS units, or different desktop units that may run Android apps?
The commonest cause app builders need to know the kind of the gadget is to allow them to decide what sort of format to indicate. However with the rise of split-screen and multi-window utilization on massive screens, making format choices primarily based on gadget sort results in incorrect format choices in sure eventualities on massive display units.
As we’ve been updating our personal apps to higher help extra units, we’ve seen a couple of necessary use instances to focus on additional. We’ll cowl 4 important eventualities:
- Layouts – Show probably the most acceptable UI for various units and folding postures
- {Hardware} options – Implement help for quite a lot of {hardware} options
- Displaying the title of the bodily gadget sort to the person – Personalize end-user going through data for the kind of gadget.
- Metrics monitoring for gadget sort – Perceive how customers are utilizing your app on several types of units
Layouts
Show probably the most acceptable UI for various units, show modes, and folding postures.
Use window measurement lessons to information format choices primarily based in your present windowing state utilizing opinionated breakpoints which are derived from frequent gadget sorts. Do not prohibit orientation or resizability; you stop customers from utilizing your utility of their desired method.
Observe folding options with Jetpack WindowManager, which gives the set of folding options that intersect your app’s present window. Word that even when your exercise isn’t receiving any folding options, it may nonetheless be operating on a tool able to folding – on the outer display, on the internal display in a small window, or on an exterior show.
Traditionally, a number of distinct layouts had been created for various display sizes, typically with a “pill” format and a “telephone” format. These two layouts then existed collectively, and each needed to be stored updated because the app modified. Referring to those layouts as “pill” and “telephone” layouts was helpful when the gadget producers by and huge restricted themselves to creating units that match cleanly into these two classes. Customers as we speak have much more selection as producers are creating units which are extra bodily different, and usable in numerous methods.
A single gadget could generally have sufficient room to show a “pill”-sized format, whereas different instances (for instance, a folded foldable or cut up display) the gadget could solely have sufficient room to show a “telephone” format. There are even instances the place a smaller format is desired equivalent to foldable flip telephone cowl shows.
This may very well be as a result of a foldable that has a smaller outer display and a bigger internal display, or each time the person enters multi-window mode and adjusts freeform windowing environments. Critically, the kind of app format shouldn’t be determined by the bodily sort of the gadget; it ought to be determined by the present measurement of the app’s window, which can or will not be full display on the present gadget show.
On massive display units operating Android 12L and better, apps that prohibit the orientation or resizability may be positioned into compatibility mode because the gadget is rotated or folded or the app enters multi-window mode. Compatibility mode letterboxes the app, preserving the app’s specified restrictions, however lacking the chance to show extra, helpful content material to the person.
{Hardware} options
Implement help for quite a lot of {hardware} options (for instance, if the gadget has a SIM).
Make dynamic, runtime choices primarily based on whether or not a characteristic is obtainable, as a substitute of assuming {that a} characteristic is or just isn’t out there for a sure type of gadget.
In case your app has a characteristic that’s completely required, Google Play respects the required uses-feature declarations in your manifest. Nevertheless, be aware that any required options cut back the set of units that your app may be put in on, and including new required options prevents updates to beforehand supported units.
There are lots of {hardware} options which are current on some Android units, however not current on others. As units proceed to evolve, we’ve seen a number of instances the place user-facing options are usually not supported, as a result of builders assume {that a} bodily sort of gadget doesn’t help a specific {hardware} characteristic.
For instance, we’ve seen instances the place biometric authentication isn’t provided as a login possibility on tablets that help biometric authentication, even when the identical app helps biometric authentication on telephones. Biometric authentication ought to be an possibility for the person if the gadget helps it, not primarily based on the kind of gadget.
One other instance is assuming mobile connectivity is restricted to standard-size telephones. Foldable units may need “pill”-sized screens, however foldables nonetheless have a mobile connection and a telephone quantity. If a tool has the potential, the person ought to be capable to select to make use of the gadget accordingly.
Some {hardware} options are additionally dynamically out there. Peripherals may be connected and indifferent by the person, and apps ought to gracefully deal with gaining and dropping entry to those options. {Hardware} options just like the digicam and microphone can solely be utilized by one app at a time, so multi-tasking between totally different apps may lead to dropping entry to {hardware} options.
Displaying bodily gadget sort to the person
Personalize user-facing data by sort of gadget (for instance, “Run in your pill”)
Referring within the UI to the person’s gadget as merely a “gadget” covers all type components and is the only to implement. Nevertheless, differentiating between the a number of units a person could have gives a extra polished expertise and lets you show the kind of the gadget to the person utilizing heuristics related to your explicit use case.
For instance, Google Play at present makes use of the next heuristics for figuring out the gadget title to show to the person when putting in an app on a specific gadget. The logic is restricted to this explicit use case, and will change as units and type components evolve.
In case you are displaying the kind of the gadget to the person, and need to differentiate between the bodily sort of the gadget for personalizing the expertise, equivalent to to say “obtain in your foldable” or to indicate extra particular gadget imagery, you need to use the out there bodily options as heuristics for which sort of gadget the person is utilizing. Nevertheless, these are solely heuristics and will change because the accepted phrases for referring to the units themselves change. As mentioned above, a foldable gadget could or could not help different {hardware} options, or have a big display.
“Foldable” heuristic:
If a tool has a hinge sensor (which may be decided by PackageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_HINGE_ANGLE)), then the gadget helps folding in some method. Word: Whereas this covers most foldables transferring ahead, it might not cowl some older foldables that don’t expose a hinge sensor. Moreover, the display the app is being displayed on could or could not fold, the gadget may need a further non-folding display as nicely, or the display could not at present be folded, even when it may fold. Gadgets just like the Samsung Flip have a smallest width of lower than 600dp, The internal display of large-screen foldables have a smallest width of 600dp or extra.
“Cellphone” heuristic:
99.96% of telephones have a built-in display with a width smaller than 600dp when in portrait, however that very same display measurement may very well be the results of a freeform/split-screen window on a pill or desktop gadget.
“Desktop” heuristic:
Desktop units, like ChromeOS units, operating Android apps, could expose particular options or setting data that apps can use. As an example, ChromeOS has the system characteristic “org.chromium.arc” or “org.chromium.arc.device_management” to allow builders to find out whether or not their app is operating on ChromeOS. However apps operating on tablets – and telephones, if the person so chooses – may use desktop-class keyboards and mice for enhanced productiveness.
Metrics monitoring for gadget sort
Perceive how customers are utilizing your app on several types of units.
Use the heuristics and options mentioned above as inputs to your analytics, whereas holding in thoughts that bodily gadget sort doesn’t give the entire story for the way customers are utilizing your app on that gadget.
Even when the person is utilizing a tool that may bodily fold, they might be utilizing the app in a number of configurations. Customers may use an app roughly on the internal display in comparison with the outer display, and so they may multi-task with different apps on the internal display. For units that help exterior shows, the app won’t be operating on both of a foldable’s built-in bodily shows.
Different data which may even be related:
- Are there exterior peripherals getting used to work together with the app, like keyboards, mice, trackpads, or styluses?
- Does the gadget have a built-in touchscreen?
- Is the app being utilized in a free-form windowing setting?
Conclusion
Do not make assumptions about what a specific bodily gadget implies on your app. “Is the gadget foldable?” is an efficient place to begin, but it surely shouldn’t be the one query you ask. Extra items of knowledge will give a extra exact and extra related reply to your use case at hand, and every use case has totally different issues that you need to make to construct versatile, adaptive apps.