Page 1 of 1

Know the device where is running my app

Posted: Fri Feb 13, 2015 7:59 pm
by aebki
Hi,

I would like to know in which device is running my app, i looked on the lessons but i didn't manage to find it, and also in the dictionary...:-(

Is is possible to know to know if it is running in one iPhone, iPad (or also android phone or android tablet) ?

What i could see is the environment ( 'mobile', 'browser', etc...), but not know the device...:-(

In fact my first target was to install the app, i made, also in one iPhone, but i had one error...And as i can't test (for the moment) , for example, in which place is appearing the keyboard ( so, which fields is hiding the keyboard in my card ) i thought that maybe it will be different depending on the devices. And for this, my reason to know in which device is running my app...

Or everything is 'easier' than what i am thinking? So, if in my iPad the keyboard is hiding the fields 6 to 10 ( in landscape) , it will be the same for the iPhone.

I hope i expressed myself well...:-)

Regards

Re: Know the device where is running my app

Posted: Sat Feb 14, 2015 10:21 pm
by jacque
See "machine" in the dictionary.

Re: Know the device where is running my app

Posted: Sun Feb 15, 2015 6:09 pm
by aebki
Hi Jacque,

Thanks for your answer...:-)

I saw in the dictionary and it is written this:
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".
So for iPhone and iPad it will work, but it means that there is no way to know if it is running on one android phone or android tablet?
I was looking for one list of manufacturer's name for the android devices and for the moment i didn't find...But even if there is one list now of devices, it means that i have to update the list each time one new device is appearing to can control if it is running on phone or tablet? :-(
It is a pity that this function is not returning one string like for iOS ( so 'iPhone' or 'iPad')...:-(

so, if it is like this, i will come back to my second question of my first post...:-)

Or everything is 'easier' than what i am thinking? So, if in my iPad the keyboard is hiding the fields 6 to 10 ( in landscape) , it will be the same for the iPhone???
and of course the same for android?

Regards.

Re: Know the device where is running my app

Posted: Sun Feb 15, 2015 6:42 pm
by jacque
It isn't practical to branch the code for every possible device, as you said. Instead you should look at the "effective working screenrect" which will give you the dimensions of the available screen space when the keyboard is showing. The last item in that rect will be the top of the keyboard, and you can determine which fields will be covered from that number.

Re: Know the device where is running my app

Posted: Sun Feb 15, 2015 11:08 pm
by aebki
Hi Jacque,

Thanks for your answer and your advice! :-)

Ok, so i will try to do what you told me! :-)

Regards.