Hi!
Does anybody have a good solution on how to determine if the user is using a tablet or a phone?
thanks!
[import]uid: 103182 topic_id: 26044 reply_id: 326044[/import]
Hmm, could be tricky.
You might be able to setup a conditional check based on various info gained from “system.getInfo”:
http://developer.anscamobile.com/reference/index/systemgetinfo
Also for iOS, I think there are some Apple-defined “hardware checks” that Corona might be able access, for example, does the device have a “ringer”, thus it would be a phone. Unfortunately I don’t know how to get this info, but it was mentioned somewhere in the forums recently.
Brent Sorrentino
[import]uid: 9747 topic_id: 26044 reply_id: 105448[/import]
I am maybe off here but won’t this work?
local device = system.getInfo( "model" )
print(device)
[import]uid: 81188 topic_id: 26044 reply_id: 105481[/import]
yes, i’ll will get the name of the device, but how do i know if it is a tablet? [import]uid: 103182 topic_id: 26044 reply_id: 105508[/import]
I don’t think i can use any information obtained by the system class to verify that its a tablet that is being used.
My solution at the moment is this :
[lua]Utils.resolutions = {}
Utils.resolutions[#Utils.resolutions+1] = {800,600}
Utils.resolutions[#Utils.resolutions+1] = {1024,600}
Utils.resolutions[#Utils.resolutions+1] = {1280,800}
Utils.resolutions[#Utils.resolutions+1] = {1024,768}
Utils.resolutions[#Utils.resolutions+1] = {2048,1536}
Utils.resolutions[#Utils.resolutions+1] = {768,1280}
–Utils.resolutions[#Utils.resolutions+1] = {800,480,“colby”,“kyros”}
function Utils.isTablet()
local res = Utils.resolutions
local device = system.getInfo( “model” )
local width = display.contentWidth
local height = display.contentHeight
local isTablet = false
for i = 1,#res,1 do
if ((width == res[i][1] and height == res[i][2]) or (width == res[i][2] and height == res[i][1])) then
if #res[i]== 2 then
isTablet = true
else
for k = 2,#res[i],1 do
if string.find(device,res[i][k]) ~= nil then
isTablet = true
end
end
end
end
end
return isTablet
end[/lua]
The code checks if the device has any of the above resolutions. This should work in most cases since these resolutions are unique for tablets only.
Do you guys think this could work? [import]uid: 103182 topic_id: 26044 reply_id: 105509[/import]
From the documentation, the “model” returns some useful info. Could you search this string for partial matches like “Pad” and “Tab” to help narrow it down? Checking the resolution(s) is also a good idea… between these two methods, I think you can determine if it’s a tablet.
system.getInfo()
‘model’ returns the device model (as specified by the manufacturer). These include…
iPhone
iPad
iPhone Simulator
iPad Simulator
Nexus One
Droid
Galaxy Tab [import]uid: 9747 topic_id: 26044 reply_id: 105516[/import]