Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Android screen size.
Started by Studycat2 Jul 25 2018 11:36 PM

9 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Studycat2

[GLOBAL: userInfoPane.html]
Studycat2
  • Enthusiast

  • 67 posts
  • Corona SDK

Hi there!

 

I'm making an app that wants to know if it is running on a screen over a certain physical size. On apple, I've determined the screen size of every apple device, and put it in a lookup table. Android is supposed to give me the correct screen size using:

local width = system.getInfo("androidDisplayWidthInInches")
local height = system.getInfo("androidDisplayHeightInInches")

However, on the 65" android Smart TV (Jector FM-A65) I am using to test, these calls are returning a w x h of 8" x 4.5", which is clearly incorrect. According to 

local approxDPI = system.getInfo("androidDisplayApproximateDpi")
local densityName = system.getInfo("androidDisplayDensityName") 

 the screen is reporting as 240 dpi, which is the "hdpi" density bucket. The content unit dimensions reported for the screen are 480 x 270. I think this information probably has little to do with the physical size of the screen, but it is the correct aspect ratio, and the tv is supposed to be 4k (hdpi). I suspect that the system is just incorrectly reporting its screen size -- but is there any way to measure the size of a screen? Is there any setting I may be missing that is stopping the app from getting the correct screen size? My build.settings file for android has the following:
 

supportsScreens =
        {
            smallScreens  = true,
            normalScreens = true,
            largeScreens  = true,
            xlargeScreens = true,
        },

Help me, Obi Wan, you're my only hope!

 

 

 



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,714 posts
  • Corona Staff

The math works out to a 1920x1080 display which is sort of standard for a HDTV (1080p).  Are you sure the TV is in 4K mode?  

 

Rob


  • Studycat2 likes this

[TOPIC: post.html]
#3

Studycat2

[GLOBAL: userInfoPane.html]
Studycat2
  • Enthusiast

  • 67 posts
  • Corona SDK

The math works out to a 1920x1080 display which is sort of standard for a HDTV (1080p).  Are you sure the TV is in 4K mode?  

 

Rob

 

Hi, Rob!

 

Our TV doesn't really have a 4K mode, per say -- when you put in a 4K compatible device as an HDMI source, it will display that as 4k, but when it is running an app as an android device, it returns the figures above. So it seems like we can't tell if it's a big display from within the app. Is this something to ask the TV manufacturer about? If so, what would we ask them?



[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,092 posts
  • Corona SDK

You asked

 

 

 is there any way to measure the size of a screen? 

 

What about pixel height and width?

https://docs.coronalabs.com/api/library/display/pixelHeight.html

https://docs.coronalabs.com/api/library/display/pixelWidth.html



[TOPIC: post.html]
#5

davebollinger

[GLOBAL: userInfoPane.html]
davebollinger
  • Corona Geek

  • 1,203 posts
  • Enterprise

what does system.getInfo return for androidDisplayXDpi  (or YDpi)?  all others are just approximations, and android devices are notoriously unreliable for most "density" measures.  (fe a tablet might "lie" so as to behave more like a phone ui)



[TOPIC: post.html]
#6

Studycat2

[GLOBAL: userInfoPane.html]
Studycat2
  • Enthusiast

  • 67 posts
  • Corona SDK

 

 

Hi! I haven't checked these, as these seem unreliable for determining a screen's physical size. With different DPIs or screen densities, a pixel count could mean anything, yes?



[TOPIC: post.html]
#7

Studycat2

[GLOBAL: userInfoPane.html]
Studycat2
  • Enthusiast

  • 67 posts
  • Corona SDK

what does system.getInfo return for androidDisplayXDpi  (or YDpi)?  all others are just approximations, and android devices are notoriously unreliable for most "density" measures.  (fe a tablet might "lie" so as to behave more like a phone ui)

 

Hi! We've checked this, and it always indicates 240. That may be correct given the resolution, but it still doesn't tell us anything about the physical size of the device, since we don't know how big it is? Here are all the display values I could find:
 

I/Corona  ( 3062): SCREEN SIZE FINDER: ANDROID, DETERMINED: dpi = 240 (hdpi), 8 inches x 4.5 inches
I/Corona  ( 3062): ANDROID KEY: androidApiLevel = 21
I/Corona  ( 3062): ANDROID KEY: androidAppVersionCode = 1
I/Corona  ( 3062): ANDROID KEY: androidAppPackageName = xxx
I/Corona  ( 3062): ANDROID KEY: androidGrantedAppPermissions = table: 0xe20f43c0
I/Corona  ( 3062): ANDROID KEY: androidDeniedAppPermissions = table: 0xe20f4480
I/Corona  ( 3062): ANDROID KEY: grantedAppPermissions = table: 0xe20f4540
I/Corona  ( 3062): ANDROID KEY: deniedAppPermissions = table: 0xe20f4620
I/Corona  ( 3062): ANDROID KEY: androidDisplayApproximateDpi = 240
I/Corona  ( 3062): ANDROID KEY: androidDisplayDensityName = hdpi
I/Corona  ( 3062): ANDROID KEY: androidDisplayWidthInInches = 8
I/Corona  ( 3062): ANDROID KEY: androidDisplayHeightInInches = 4.5
I/Corona  ( 3062): ANDROID KEY: androidDisplayXDpi = 240
I/Corona  ( 3062): ANDROID KEY: androidDisplayYDpi = 240
I/Corona  ( 3062): ANDROID KEY: actualContentHeight = 320
I/Corona  ( 3062): ANDROID KEY: actualContentWidth = 568.88891601562
I/Corona  ( 3062): ANDROID KEY: contentCenterX = 240
I/Corona  ( 3062): ANDROID KEY: contentCenterY = 160
I/Corona  ( 3062): ANDROID KEY: contentHeight = 320
I/Corona  ( 3062): ANDROID KEY: contentScaleX = 0.29629629850388
I/Corona  ( 3062): ANDROID KEY: contentScaleY = 0.29629629850388
I/Corona  ( 3062): ANDROID KEY: contentWidth = 480
I/Corona  ( 3062): ANDROID KEY: currentStage = table: 0xe2014820
I/Corona  ( 3062): ANDROID KEY: fps = 30
I/Corona  ( 3062): ANDROID KEY: imageSuffix = @2x
I/Corona  ( 3062): ANDROID KEY: pixelHeight = 1920
I/Corona  ( 3062): ANDROID KEY: pixelWidth = 1080
I/Corona  ( 3062): ANDROID KEY: safeActualContentWidth = 520.88891601562
I/Corona  ( 3062): ANDROID KEY: safeActualContentHeight = 288
I/Corona  ( 3062): ANDROID KEY: safeScreenOriginX = -20
I/Corona  ( 3062): ANDROID KEY: safeScreenOriginY = 16
I/Corona  ( 3062): ANDROID KEY: screenOriginX = -44
I/Corona  ( 3062): ANDROID KEY: screenOriginY = -0
I/Corona  ( 3062): ANDROID KEY: statusBarHeight = 0
I/Corona  ( 3062): ANDROID KEY: topStatusBarContentHeight = 0
I/Corona  ( 3062): ANDROID KEY: viewableContentHeight = 320
I/Corona  ( 3062): ANDROID KEY: viewableContentWidth = 480


[TOPIC: post.html]
#8

Studycat2

[GLOBAL: userInfoPane.html]
Studycat2
  • Enthusiast

  • 67 posts
  • Corona SDK

Bump?



[TOPIC: post.html]
#9

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,714 posts
  • Corona Staff

There really isn't anything to bump here. We are at the mercy of what the device tells us. We are just calling Android API's to return that data to Corona. We are not calculating or doing device testing or anything more than reporting what the device says.

 

Rob



[TOPIC: post.html]
#10

jasson.archimedes

[GLOBAL: userInfoPane.html]
jasson.archimedes
  • Observer

  • 4 posts
  • Corona SDK

 



 

What program are you using to modify your code? Subway Surfers Psiphon Hill Climb Racing




[topic_controls]
[/topic_controls]