system.getInfo("model") does not return consistently, or as advertised :(

System.getInfo(“model”) returns the general model names (“iPad,” “iPod Touch”) of iDevices but precise model numbers (“GT-P7510” for a Galaxy Tab 10.1 and “ADR6300” for a Droid Incredible) for Android devices?

If so, why the inconsistency?

According to the API page, it is supposed to return like this:

“iPhone”
“iPad”
“iPhone Simulator”
“Nexus One”
“Droid”
“myTouch”
“Galaxy Tab”

Is there a way to get it to do that? Or get something to do that? Thanks! [import]uid: 111461 topic_id: 19635 reply_id: 319635[/import]

Unfortunately this is the way it is supposed to work. It wasn’t clear to me either, and caused me to headaches until I realized what was actually being returned.

I found the ONLY way I could actually get consistent results when both in the simulator AND one the device was to use a text file that specified the platform.

platform_kindle.txt
platform_android.txt
etc

then I make a “staging” area using a batch file to copy all of the necessary files from my working directory and when I do that I rename the platform_*.txt file I am building for to “platform.txt”.

This allows me to check if platform.txt exists, and if so to read in the string inside. Then I use that to base all of my platform specific logic.

BTW, this isn’t necessary for iOS devices since the documentation is correct regarding the values you get back for the iOS platform.

This allows me to load my project from a staging area and see it function as if it was on the device.

[lua]local platformPath = system.pathForFile( “platform.txt”, system.ResourceDirectory )
local platformFile = io.open( platformPath, “r” )
local platformString = “”

if platformFile then
platformString = platformFile:read( “*a” )
io.close( platformFile )
end

local nDroid = string.find( platformString, “android” )
if ( nDroid ) then
– set some android specific values here
end

local nKindle = string.find( platformString, “kindle” )
if ( nKindle ) then
– set some kindle specific values here
end[/lua]

Hope that helps.

[EDIT] One other advantage to having a staging area is that the Android platform can be VERY picky about having certain files in sub-folders. So you can have your main working area as organized as you like, then copy everything into a flat folder structure for building your Android builds. This will save you all sorts of heartache.

Ken [import]uid: 16734 topic_id: 19635 reply_id: 75927[/import]

Ken - I can’t tell if you’ve solved my problem, or if your solution addresses a problem different from mine.

My problem is that I can’t figure out a way to tell what sort of Android device I’m on (specifically - what screen size I’m using). I can determine whether or not I’m on an Android device, but I don’t know if my screen size is Droid, or Galaxy Tab, or Nexus One.

Does your solution differentiate between different flavors of Android devices? Or is it just a build system for breaking up assets between different types of devices? [import]uid: 65996 topic_id: 19635 reply_id: 76012[/import]

The system.getInfo(“model”) returns whatever the manufacturer has programmed it to return. We don’t control it, but only report the information. [import]uid: 7559 topic_id: 19635 reply_id: 76023[/import]

@Simon,

No, this won’t help you determine the model. If all you need is the actual screen size, then you can use this:

[lua]actualScreenWidth = display.contentWidth / display.contentScaleX
actualScreenHeight = display.contentHeight / display.contentScaleY[/lua]

[EDIT]

To account for letterbox borders you should use the following calculation:

[lua]actualScreenWidth = math.round((display.contentWidth-2*display.screenOriginX) / display.contentScaleX)
actualScreenHeight = math.round((display.contentHeight-2*display.screenOriginY) / display.contentScaleY)[/lua]

NOTE: Due to rounding error you may end up with an off by 1 error. For instance using the above calculation in the simulator for Droid, you get 853 x 480, whereas the actual size should be 854 x 480. This is why I requested that Ansca add display.physicalWidth, display.physicalHeight to the display properties, but so far they haven’t wanted to do that.
[import]uid: 16734 topic_id: 19635 reply_id: 76021[/import]

@Tom,

Any chance of getting display.physicalWidth, display.physicalHeight added so we can accurately know the actual screen width/height? This isn’t just a request with no good reason, there are legitimate reasons for knowing the device resolution. [import]uid: 16734 topic_id: 19635 reply_id: 76035[/import]