Interface GeoFenceCallback


  • public interface GeoFenceCallback
    Callback routine for IWPS.setGeoFence().
    For a WPS_GEOFENCE_ENTER geofence, this callback will be called whenever the user enters the geofence (but only once for as long as the user remains inside the geofence).
    For a WPS_GEOFENCE_LEAVE geofence, this callback will be called whenever the user leaves the geofence (but only once for as long as the user remains outside the geofence).
     Sample Code:
     
        public WPSContinuation handleGeoFence(final WPSGeoFence geofence,
                                              final WPSLocation location)
        {
            if (geofence.getType() == WPSGeoFence.Type.WPS_GEOFENCE_ENTER)
            {
                System.out.println("entering");
            }
            else // geofence.getType() == WPSGeoFence.Type.WPS_GEOFENCE_LEAVE
            {
                System.out.println("leaving");
            }
    
            final String pattern = " geofence"
                                   + " ({0,number,#.######},"
                                   + " {1,number,#.######}"
                                   + " +/-{2, number,#}m)"
                                   + " at {3,number,#.######},"
                                   + " {4,number,#.######}"
                                   + " +/-{5, number,#}m";
    
            System.out.println(MessageFormat.format(pattern,
                                                    geofence.getLatitude(),
                                                    geofence.getLongitude(),
                                                    geofence.getRadius(),
                                                    location.getLatitude(),
                                                    location.getLongitude(),
                                                    location.getHPE()));
    
            return WPSContinuation.WPS_CONTINUE;
        }
     
     
    Since:
    4.4
    • Method Detail

      • handleGeoFence

        WPSContinuation handleGeoFence​(WPSGeoFence geofence,
                                       WPSLocation location)
        Parameters:
        geofence - that triggered this callback
        location - that triggered this callback
        Returns:
        WPS_CONTINUE if this geofence tracking should continue,
        WPS_STOP if tracking should be cancelled (and no more callbacks will be invoked).