2 years ago
#47061

Adam Burley
Pixel 6 changes reported screen size based on orientation - how to get the screen size in a stable way?
We use the "screen size" resource qualifier to determine the size of the device - roughly speaking whether it's a phone or a tablet. This is because our app is meant to start in portrait mode on a phone and landscape mode on a tablet.
We found an apparent bug in Pixel 6 on Android 12 - when the display size is set to small (OS settings -> Display -> Display size) and the orientation is portrait, the OS reports the screen size as "large". If it's in landscape, it reports as "normal" (which is what we would expect). We tried this on other devices including Pixel 3a, 4a and some Samsung devices and it doesn't behave this way on those - so only the Pixel 6 had this problem of those we tested.
(In code, context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK
is equal to 3 in portrait and 2 in landscape).
This caused a bug in our app that made us all seasick - the orientation changes back and forth between portrait and landscape all the time, as it keeps detecting it as a large device and then rotating it and then it's no longer a large device and rotated back.
Given this weird behaviour, is there any way to reliably determine the screen size in a way that would differentiate "phones" and "tablets" as one would expect?
android
orientation
google-pixel
0 Answers
Your Answer