Using the tools Livecode provides for reading mobile device sensors, construct a simple app that displays the readings from a mobile phone such as an iPhone.
See the lesson on Mobile Device Sensors for a more complete description of how to access sensors using LiveCode.
radioBehavior
property is set to true.on preOpenStack if the environment is "mobile" then mobileSetAllowedOrientations "portrait,portrait upside down" end if end preOpenStack
on mouseUp stopAllSensors -- clear the current sensor tracking setting put the hilitedButtonName of me into tSensor mobileStartTrackingSensor tSensor, false end mouseUp on stopAllSensors repeat with x = 1 to the number of btns in me put the short name of btn x of me into tSensor mobileStopTrackingSensor tSensor end repeat end stopAllSensors
on preOpenCard initCard send "stopAllSensors" to group "sensorGrp" end preOpenCard on initCard put empty into fld "sensorReport" set the hilitedButtonName of group "sensorGrp" to empty end initCard
locationChanged
message, which receives data from the location sensors when that sensor is turned on:
on locationChanged pLat, pLong, pAlt put "Your location has changed: " & return & \ "latitude: " & pLat & return & "longitude: " & pLong & return & \ "altitude: " & pAlt into fld "sensorReport" end locationChanged
Set up the standalone application settings so that this app can be tested on actual devices. The following screen shots show what settings need to be selected. Note that the specific desired sensors need to be enabled on the devices for these commands above to work: