Search code examples
androidgoogle-mapsgeofire

onKeyExited method not executed in GeoFire Android


@Override
    public void onLocationChanged(Location location) {
       if (location != null) {
            GeoQuery query = geoFire.queryAtLocation(
                new GeoLocation(location.getLatitude(), location.getLongitude()),
                DistanceConstants.FILTER_DISTANCE
        );

        query.addGeoQueryEventListener(this);
       }
    }

@Override
    public void onKeyExited(String key) {
        Toast.makeText(context, "Key removed", Toast.LENGTH_SHORT).show();
    }

The OnKeyEntered() is executed properly based on my needs. The results are also perfect. However, OnKeyExited() method is never executed. I have 0.2 KM as the radius and whenever new keys are appearing within my 0.2 KM they are getting added but those are leaving my area of interest, they are not getting removed.

Any particular reason for this?


Solution

  • I was an idiot. Needed to use the setCenter() to update my query and everything is working as expected.