Page 1 of 1

device detection ?

Posted: Tue May 15, 2012 11:55 am
by d.m.holdawayGA2553
hello,

does anyone have or know of a device detection script example that i can look at

i want to be able to detect the different devices then load the correct graphics depending on which device it is.

any advice or examples are welcome.

Re: device detection ?

Posted: Tue May 15, 2012 11:58 am
by Klaus
Hi d.m.holdawayGA2553,

check "environment", "platform" and "machine" in the dictionary.
"machine" might be what you are looking for.


Best

Klaus

Re: device detection ?

Posted: Tue May 15, 2012 12:35 pm
by d.m.holdawayGA2553
i checked machine and it does not seem to cover mobile devices such as iphones and android based smart phones.

Re: device detection ?

Posted: Tue May 15, 2012 1:02 pm
by Klaus
d.m.holdawayGA2553 wrote:i checked machine and it does not seem to cover mobile devices such as iphones and android based smart phones.
Things ain't what they SEEM to be!
From the dictionary:
.....................................................
Value:
The machine function returns a string.

* x86 - windows based system
* iPod Touch - the device is one of the iPod Touch models
* iPhone - the device is one of the iPhone models
* iPhone Simulator - the device is a simulated iPhone
* iPad - the device is the iPad
* iPad Simulator - the device is a simulator iPad

Comments:
On Mac OS systems, the machine function uses the Gestalt() system call to determine the machine type.

On Unix systems, the machine function uses the uname() system function.

On Android devices, the machine function returns the manufacturer's name for the device. For example, if running on a Google Nexus One, the string is "Nexus One".
........................................................
BOLD formatting by me.
This info SEEMS (sic!) sufficient to me 8)


Best

Klaus

Re: device detection ?

Posted: Tue May 15, 2012 1:04 pm
by d.m.holdawayGA2553
well i looked at the online dictionary and it did not mention the devices.

Re: device detection ?

Posted: Tue May 15, 2012 1:25 pm
by Klaus
East, West, home is best! :)

Re: device detection ?

Posted: Wed Aug 08, 2012 12:26 pm
by d.m.holdawayGA2553
so i could use this to get my app to work on different devices then?

example..

so i would load the device id into a twhatdevice

if twhatdevice = "iphone" go card "iphonemain"
etc etc

so i might need to build about 40 different cards to cover the amount of different android devices..

Re: device detection ?

Posted: Wed Aug 08, 2012 2:30 pm
by sturgis
Ok, for the iphone you might want to look at
iphoneDeviceScale() -- will let you know if you are on retina or not
iphoneUseDeviceResolution()
iphoneDeviceResolution()

This way you can determine if the device has a retina display, then you can either work with logical points or pixels depending on the setting of iphoneUseDeviceResolution

For android I suggest looking at the screenrect. You can then use this information to determine how you want to put together your screens.