0

I have an operational Android app which reports users location within a background service. I want to integrate a feature which will notify the user when GPS signal has been lost.

Our current implementation to commence location updates is:

    mLocationListener = LocationListener(LocationManager.GPS_PROVIDER, gpsDeviceCallback)
    if (handlerThread?.isAlive == true) {
        handlerThread?.quit()
    }
    handlerThread = HandlerThread("GpsLocationHandler")
    handlerThread!!.start()
    mLocationManager?.requestLocationUpdates(
            LocationManager.GPS_PROVIDER, LOCATION_INTERVAL, LOCATION_DISTANCE.toFloat(),
            mLocationListener, handlerThread!!.looper)

with LOCATION_INTERVAL set to 1000 ms and LOCATION_DISTANCE set to 10m.

We get the expected onLocationChanged callbacks under normal operation. However, I would appreciate advice on how to detect a situation where there is a loss of GPS or handset cannot obtain an adequate GPS signal.

We have implemented a solution where we run a time task and determine if onLocationChanged is called during the timer period. The problem with this solution is that if the user handset is stationary during this time then no onLocationChanged callbacks will happen. So this approach will not work as a means of detecting no\inadequate GPS signal.

The user of onStatusChanged as a method of LocationListener is now deprecated so this is not an option either.

Is there some standard solution to this problem ? Perhaps some method which could be called in the case where no onLocationChanged callbacks happen when our check timer expires to test current GPS status?

Thanks!

1 Answers1

0

you can check the current connected satellites and approximate the accuracy see :https://stackoverflow.com/a/10589949

Code Demon
  • 894
  • 1
  • 5
  • 9