mobile sensor reading

Ralph DiMola rdimola at evergreeninfo.net
Fri Mar 21 19:52:28 EDT 2014


-----Original Message-----
From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On Behalf
Of Devin Asay
Sent: Friday, March 21, 2014 6:40 PM
To: How to use LiveCode
Subject: mobile sensor reading

Has anyone successfully used the mobileSensorReading() function? I have
tried it both in the simulator and on devices but it doesn't seem to report
the expected sensor data. (I have been able to get sensor data using
mobileStartTrackingSensor in conjunction with the sensor messages, but no
luck with the mobileSensorReading function. Does it have to be used in
conjunction with mobileStartSensorTracking, or does it stand by itself.
Anyone know?

Devin
---------------------
Devin,

I have always used it like that. 

I do a:

if not dev() then
      if mobileSensorAvailable("location") then
         mobileStartTrackingSensor "Location", false
      end if
   end if

in the preopenstack

I also found that in some cases a reading is good the second time around if
this is the first app that requested a GPS lock from the HW

So I do this just in case and it seems to be working well out in the field.

function GetGpsCords
   
   local tGPS
   
   if not mobileSensorAvailable("location") then return empty
   put mobileSensorReading("location", true) into tGPS
   if tGPS["latitude"] is not empty and tGPS["longitude"] <> 0 then
      wait .25 seconds
      put mobileSensorReading("location", true) into tGPS
   end if
   if tGPS["latitude"] is not empty and tGPS["longitude"] <> 0 then
      return tGPS
   else
      answer "GPS is not enabled or your GPS can't determine your location."
& cr & \
            "If your GPS was just enabled, please try again in a few
minutes." \
            with "OK" titled "Proximity Search"
      return empty
   end if
   
end GetGpsCords

Ralph DiMola
IT Director
Evergreen Information Services
rdimola at evergreeninfo.net






More information about the use-livecode mailing list