I am trying to read the real physical display resolution on my Android TV device. I have two testing TVs:
- FullHD with 1920 x 1080 resolution
- UHD with 3840 x 2160 resolution
and 1 Android TV HDMI stick with Android 9.
I would like to read out the real physical screen resolution depending on the TV device. For this I tried reading out the displayMetrics in 2 ways:
attempt:
context.resources.displayMetrics
attempt:
val displayMetrics = DisplayMetrics() activity.display?.getRealMetrics(displayMetrics)
Unfortunately, my UHD device shows me 1920x1080 for both mentioned attempts. I am not interessted in some scaled down display resolution.
EDIT: As @IanGClifton answered I tried it with DisplayCompat
. I have a AndroidTV "Stick" running on Andorid 9 which is plugged to any TV (plugged into the above mentioned UHD TV with 3840x2160 px) device via HDMI. I flash the Stick and the physicalWidth
and physicalHeight
still tell me 1920x1080 pixels.
val defaultDisplay = activity.windowManager.defaultDisplay
val mode = DisplayCompat.getMode(context, defaultDisplay!!)
Log.d(TAG, "Resolution ${mode.physicalWidth} x ${mode.physicaHeigth}.")
But, when I flash the Android TV device (not the Android TV stick) directly, I get proper resolution.
How can I read out the real native physical display resolution in pixels for any devices?