Search code examples
androidgpslocationmanagerlocationlistener

How to Find GPS Signal is Lost in Android?


Is there a way to find out that the GPS signal is lost? I am not talking about whether GPS Module is enabled/disabled. Suppose that GPS Module is enabled; but fix is lost?

This How can I check the current status of the GPS receiver? link is not useful; since you cannot use that solution in the case which user is stationary for a certain period of time("LocationListener" stops listening to location updates; after you receive couple of updates upon first fix).

More than that, unlike on gingerbread, on my Nexus 4(which has Jelly Bean 4.2.2) "onStatusChanged" method of "LocationListener" is not called anymore! I dont know whether it depends on being stationary or not; yet it doesn't mean anything for me again.

On the other hand, My API is compiled via API 10, however in that release, no action called "GPS_FIX_CHANGE" had been declared in "LocationManager" class at that time.

What should i do to have my app notified of signal lost and gained events?

Kind Regards


Solution

  • Android and iphone both have a stand still filter enabled, which as you described, leads to the situation that you don't get a location update when standing still.
    I would just ignore that, and use the Location.accuracy value for each new location received. If that values exceeds 30m then it is bad GPS.

    While standing you could decide to do nothing.
    Theoretically there is a solution for your task, but with drawbacks:
    When you don't get a new location for some time, you can disable and reenable Location Service every 5 seconds. Then in case of good GPS you get a new coordinate, or none if there is no GPS signal available.