PDA

View Full Version : Is it possible to generate an event when the Device is placed on a flat surface?




fenrus110
Nov 17, 2008, 05:20 PM
Not sure if this is even possible, but my client wants to auto bring up the keyboard and rotate the view to Landscape when the Device is placed on a flat surface.

From my experiences, rotation events only trigger if the device is perpendicular to the ground.

Not to mention, how the Device would know if the device is on the palm of a hand or on a table...



chrisesposito
Nov 17, 2008, 06:20 PM
Checking the accelerometer values will give you the info you need, although you will probably need to accept a small range of rotation angles that are close enough to level in 2 axes that the surface can be considered "flat" - did you really mean "perpendicular to the gravity vector" when you said "flat'?

Chris

firewood
Nov 17, 2008, 07:33 PM
Not to mention, how the Device would know if the device is on the palm of a hand or on a table...

A human palm rarely stay as motionless as a table. Find a Tai Chi master, have him hold an iPhone as flat as possible for a few seconds. Any less deviation found by the accelerometer in the X and Y axis's over the course of a few seconds, and it's probably a table top.

.