3

I have successfully been getting GPS data through the registerLocationListener() and onLocationChanged() methods. The only problem with this is that the speed reading of my app freezes if there is no more GPS data (e.g. when I go indoors, enter a tunnel, etc). The behavior I want for my app is that the user is somehow notified that the speed reading is probably not accurate due to a lack of fresh data (set speed to zero, blink the speed reading, etc).

How can I do that? I though of checking periodically whether the GPS unit was detecting any satellites, but I'm not sure how to force periodic checks.

Janusz
  • 187,060
  • 113
  • 301
  • 369
Chris
  • 4,212
  • 5
  • 37
  • 52
  • Maybe you could use a GpsStatus.Listener, although I faced some problems with it (see my post http://stackoverflow.com/questions/3287389/gpsstatuslistener-no-satellites-used-in-fix-although-status-is-gpsstatus-gps-eve). Recently I faced similar task, which is why I am now running two requestLocationUpdates with a gps_provider and a network_provider at the same time. – Mathias Conradt Jul 25 '10 at 06:49

1 Answers1

3

Maybe you could just start a periodic timer. If timer sees that last GPS fix is old it displays notification. Application should remember when the last fix was.

Fedor
  • 43,261
  • 10
  • 79
  • 89
  • This is pretty much what I ended up doing after an unsuccessful attempt at using GpsStatus.getSatellites() and GpsSatellite.usedInFix(). Whenever I get a new Location object in my LocationListener, I set a timestamp with System.currentTimeMillis() and then compare the time each time I receive an update in my GpsStatus.Listener. It's primitive, but so far it's the only solution I found that works... – Chris Aug 02 '10 at 14:05