Page 1 of 1

GPS - Feature, Application Crash

Posted: Fri Jul 27, 2012 9:04 am
by Simon Knight
I am developing an application that reads data from the sensors available on a Galaxy S2 handset. The routine EnableSensors is called when the application starts reading data and the DisableSensors when no more data is required.

If the GPS is navigating and DisableSensors is run shortly followed by EnableSensors then the application crashes. If however the GPS was only searching then all is well. If the selection of EnableSensors is delayed for a short while then all is well.

The crash occurs as the GPS transitions from search to navigate (pulsing indicator to steady)

Code: Select all

On EnableSensors
   try
   mobileStartTrackingSensor "location", false       --false means use most accurate (GPS)
   mobileStartTrackingSensor "heading", false       --false means use most accurate
  mobileStartTrackingSensor "acceleration", false  --false means use most accurate
  put "Sensors: location and heading  have been enabled at maximum accuracy." into tdebug
  printerror tDebug
catch TheError
   answer "Enable Sensors reports : " & TheError
   end try
end EnableSensors

On DisableSensors
    mobileStopTrackingSensor "location"
   mobileStopTrackingSensor "heading"
   mobileStopTrackingSensor "acceleration"
   put "Sensors: location, heading and acceleration have been disabled." into tDebug
   printerror tDebug
end DisableSensors

Re: GPS - Feature, Application Crash

Posted: Fri Jul 27, 2012 2:54 pm
by sturgis
Your code works perfectly for me on an htc evo, android 4.03. Only changed the logging to use my stuff.

Have you tried starting the sensors singly? At least that way you can determine if there is a specific sensor that causes the trouble.

Re: GPS - Feature, Application Crash

Posted: Sat Jul 28, 2012 9:51 am
by Simon Knight
Good idea, I'll have a look when I get a moment. Good to know that it works on Android 4.03 and a different handset.

best wishes

Simon