Best way to determine iPad or other tablet?

Thanks for the useful information everyone! I have a question related to the Android tablet detection while working in the simulator. Right now, I’m getting a nil value whenever I call  androidDisplayApproximateDpi or the androidDisplayWidth(Height)InInches arguments with getInfo.

Is that expected behavior? If so, is there a method to develop on the simulator and still determine tablet/phone status for Android? I’m in a situation where my object layout would be determined by the physical size of the device. iOS is easy, but no go with Android so far.

How do you go about determining the physical size / DPI on iOs devices?

@runewinse,

First, I’d check system.getInfo(), but I think it only gives DPIs for Android.

Next, I’d simply create a table of all iOS devices and store their DPIs in my app.  This should take about 15 minutes.

Finally, I’d use system.getInfo() to find the exact iOS device I’m on and get the DPI from the table:

https://docs.coronalabs.com/daily/api/library/system/getInfo.html#architectureinfo

Not elegant, but quick and easy.

Here are couple of useful links if you find you want to go the lookup route I provided:

@elbowroomapps

What’s the best way to future proof this code for iPhones?

 

I’m thinking of a case where a new iPhone is released and you don’t have time to immediately push out an update. 

I would be inclined to have a json file on a server with some of these device details in it, that way you just need to update that file with the new device details, and not have to resubmit to the stores.  

Even if you need new artwork, that could be pulled from the server/S3/etc if the image name is included in the json data.

Thanks for the tip, roaminggamer!

I have no apple computer to build iOS apps with, nor any iOS devices to test on, so it might be a while before I can actually test these things…  :smiley:

How do you go about determining the physical size / DPI on iOs devices?

@runewinse,

First, I’d check system.getInfo(), but I think it only gives DPIs for Android.

Next, I’d simply create a table of all iOS devices and store their DPIs in my app.  This should take about 15 minutes.

Finally, I’d use system.getInfo() to find the exact iOS device I’m on and get the DPI from the table:

https://docs.coronalabs.com/daily/api/library/system/getInfo.html#architectureinfo

Not elegant, but quick and easy.

Here are couple of useful links if you find you want to go the lookup route I provided:

@elbowroomapps

What’s the best way to future proof this code for iPhones?

 

I’m thinking of a case where a new iPhone is released and you don’t have time to immediately push out an update. 

I would be inclined to have a json file on a server with some of these device details in it, that way you just need to update that file with the new device details, and not have to resubmit to the stores.  

Even if you need new artwork, that could be pulled from the server/S3/etc if the image name is included in the json data.

Thanks for the tip, roaminggamer!

I have no apple computer to build iOS apps with, nor any iOS devices to test on, so it might be a while before I can actually test these things…  :smiley: