STWGeolocationManager

open class STWGeolocationManager

STWGeolocationManager

Public Class that manages all operations concerning geolocation tracking.

The main function of this class is to detect and stream location data to send it to the server or

to update a map to smoothly watch location updates as they change in the real world

This class offers several possible operations defined in the following list:

  • Start or stop tracking the user' location
  • Start or stop tracking other users' locations
  • Send a request to change the geolocation tracking rules
  • get the current active tracking rule
  • get all available tracking rules
  • Search for places by keyword
  • Find address from specific position
  • Get detailed address from specific position : address, zipCode, city, country, state
  • Get updates about geolocation changes by registering to STWGeolocationFeaturesListener
  • Get the geolocation tracking status of the subscriber which can be OFF, on REQUEST or on TRACKING

 

For starting the location service


    STWGeolocationManager.getInstance().startTrackingDeviceLocation(context,
        new TrackingDeviceLocationCallback() {
            
            public void onSuccess() {
                 //Code...
             }

             
             public void onError(GeolocationError error) {
                 //Code...
              }
  });

 

To start tracking other users' locations


       STWGeolocationManager.getInstance().startTrackingParticipantsLocations(users, refreshTime, new StartTrackingParticipantsCallback() {
                
                public void onStartTracking() {
                    // code
                }

                
                public void onError(GeolocationError error) {
                    // code
                }
            });

 

Change the geolocation tracking rule

 

A tracking rule is a configurable condition that can be added from the administration platform to

determine a time interval for the tracking.



    STWGeolocationManager.getInstance().changeGeolocationTrackingRuleRequest(context, ruleUUID,
         new ChangeTrackingRuleCallback() {
            
            public void success() {
                 //Code...
            }

            
            public void onError(GeolocationError error) {
                 //Code...
            }
     });

 

Search for places by keyword


    STWGeolocationManager.getInstance().searchForPlaces(this, query, new STWSearchPlaceListener() {
            
            public void onComplete(ArrayList<LocationAttachment> locations) {
                 //Code...
            }

            
            public void onError(GeolocationError error) {
                 //Code...
            }
        });

 

Find address from specific position



    STWGeolocationManager.getInstance().getAddressFromPosition(location.getLatitude(),
          location.getLongitude(), new STWRequestAddressListener() {
            
            public void onComplete(String address) {
                 //Code...
            }

            
            public void onError(GeolocationError error) {
                 //Code...
            }
     });

Functions

Link copied to clipboard
open fun canChangeGeolocationFeature(@NonNull context: Context): Boolean
Gets whether the user is able to deactivate the geolocation feature or not
Link copied to clipboard
open fun changeGeolocationTrackingRuleRequest(    @NonNull context: Context,     @NonNull ruleUUID: String,     @Nullable listener: ChangeTrackingRuleCallback)
The ability to change the tracking rule may apply to users for whom the tracking option is enabled.
Link copied to clipboard
open fun enableGeolocationBatteryOptimization(@NonNull context: Context, enabled: Boolean)
By ignoring the geolocation battery optimization option, listening of motion sensor will be removed to keep listening for location services periodically.
Link copied to clipboard
open fun enableGeolocationWakeUp(@NonNull context: Context, enabled: Boolean)
Enable or not the geolocation wakeup feature locally
Link copied to clipboard
open fun enableRealtimeGeolocationMode(@NonNull context: Context, enabled: Boolean): Boolean
Enable/Disable the realtime geolocation mode
Link copied to clipboard
open fun getActiveGeolocationTrackingRule(@NonNull context: Context): GeolocTrackingRulesItem
Get the current active geolocation tracking rules
Link copied to clipboard
open fun getAddressFromPosition(    latitude: Double,     longitude: Double,     @Nullable listener: STWRequestAddressListener)
Call this method to get the address information from a position
Link copied to clipboard
open fun getAllTrackingRules(@NonNull context: Context): List<GeolocTrackingRulesItem>
Call this method to get all tracking rules added from the backend
Link copied to clipboard
open fun getArcGisMaxZoomLevel(@NonNull context: Context): String
Get ArcGis Max Zoom Level
Link copied to clipboard
open fun getConfiguredMinDistanceForFastTracking(@NonNull context: Context): Double
Call this method to get the minimum distance configured for fast tracking only if the distance based location feature is enabled
Link copied to clipboard
open fun getCountryCodeFromPosition(    latitude: Double,     longitude: Double,     @Nullable listener: STWRequestCountryCodeListener)
Call this method to get country code from the given position
Link copied to clipboard
open fun getCountryCodeFromUserPosition(@NonNull context: Context, @Nullable listener: STWRequestCountryCodeListener)
Call this method to get the country code from user position
Link copied to clipboard
open fun getDetailedAddressFromPosition(    latitude: Double,     longitude: Double,     @Nullable listener: STWRequestDetailedAddressListener)
Call this method to get detailed address information from a position
Link copied to clipboard
open fun getGeolocationStatus(@NonNull context: Context): Int
Gets The subscriber geolocation status:
Link copied to clipboard
open fun getImageFileNameEnding(@NonNull context: Context): String
Link copied to clipboard
open fun getInstance(): STWGeolocationManager
Get or create the single instance of STWGeolocationManager.
Link copied to clipboard
open fun getLocationDateTime(@NonNull location: Location): Long
Call this method to get the time of the location, in elapsed real-time since system boot.
Link copied to clipboard
open fun getLocationIcon(@NonNull iconName: String): Bitmap
Gets the location icon corresponding to the given iconName.
Link copied to clipboard
open fun getMapConfig(): MapConfig
Link copied to clipboard
open fun getMapProvider(@NonNull context: Context): MapProvider
Accessor.
Link copied to clipboard
open fun getMapProviderValue(@NonNull context: Context): Long
Gets the current map provider value
Link copied to clipboard
open fun getOSMBaseTiles(): String
Retrieve the OSM base URL used to download tiles.
Link copied to clipboard
open fun getParticipantTrackingPeriod(@NonNull context: Context): Long
Link copied to clipboard
open fun getTrackingInterval(@NonNull context: Context): Long
The location tracking interval is configured from the backend.
Link copied to clipboard
open fun getTrackingRulesCount(@NonNull context: Context): Int
Call this method to get all tracking rules count added from the backend
Link copied to clipboard
open fun getWMTSBaseTiles(@NonNull context: Context): String
Retrieve the WMTS base URL used to download tiles.
Link copied to clipboard
open fun getZoomLevel(@NonNull context: Context): String
Get Zoom Level
open fun handleLocationCouldBeSentAfterLocationPermissionGranted()
check if location could be sent : if is true launch geolocation in case of subscriberStatus is onTracking, else stop geolocation
Link copied to clipboard
open fun initMapConfig(@NonNull mapConfig: MapConfig)
Initialize the configuration related to the Map provider
Link copied to clipboard
open fun isChangingDistanceBasedLocationAllowed(@NonNull context: Context): Boolean
Allow the subscriber to activate or deactivate the distance based location feature.
Link copied to clipboard
open fun isChangingTrackingRulesEnabled(@NonNull context: Context): Boolean
Allow or not the subscriber to change geolocation tracking rules
Link copied to clipboard
open fun isDispatcher(@NonNull context: Context): Boolean
Call this method to check whether user is dispatcher manager ot not
Link copied to clipboard
open fun isGeolocationBatteryOptimizationEnabled(@NonNull context: Context): Boolean
Check if Geolocation battery optimization is enabled
Link copied to clipboard
open fun isGeolocationEnabled(@NonNull context: Context): Boolean
If the subscriber allow the geolocation
Link copied to clipboard
open fun isGeolocationTrackingRulesEnabled(@NonNull context: Context): Boolean
Check if the subscriber is allowed to change the geolocation tracking rule
Link copied to clipboard
open fun isGeolocationWakeUpAllowed(@NonNull context: Context): Boolean
Check if Geolocation Wakeup Device Feature is allowed from the backend
Link copied to clipboard
open fun isGeolocationWakeUpEnabled(@NonNull context: Context): Boolean
Check if Geolocation Wakeup Device feature is allowed locally by the user
Link copied to clipboard
open fun isLocationAcceptable(@NonNull newLocation: Location, @Nullable oldLocation: Location): Boolean
Determines whether one Location is better than the given location For Android 12 determining if the new location is acceptable compared to the old one is unuseful when the permission is accepted only for approximation and the return will be true.
Link copied to clipboard
open fun isRealtimeGeolocationEnabled(@NonNull context: Context): Boolean
Check if the realtime geolocation mode is enabled or not
Link copied to clipboard
open fun registerBeaconServiceListener(@NonNull listener: STWServiceListener)
Register the listener to handle Beacon service events.
Link copied to clipboard
open fun registerDispatcherStatusListener(@NonNull listener: STWDispatcherStatusListener)
Register to dispatcher status listener
Link copied to clipboard
open fun registerGeolocationChangesListener(@NonNull listener: STWGeolocationFeaturesListener)
register for geolocation changes listener
Link copied to clipboard
open fun registerGeolocationServiceListener(@NonNull listener: STWServiceListener)
Register the listener to handle geolocation service events.
Link copied to clipboard
open fun registerTrackingLocationListener(@NonNull listener: STWTrackingDeviceLocationListener)
Register the listener that will be notified by the user' location tracking events.
Link copied to clipboard
open fun registerTrackingParticipantsService(@NonNull listener: STWTrackingParticipantsListener)
Register the listener to handle tracking participants service events.
Link copied to clipboard
open fun searchForPlaces(    @NonNull context: Context,     @NonNull searchKey: String,     @Nullable listener: STWSearchPlaceListener)
Call this method to handel search for places based on a keyword
Link copied to clipboard
open fun startTrackingDeviceLocation(@NonNull context: Context, @Nullable listener: TrackingDeviceLocationCallback)
Call this method to start the location tracking
Link copied to clipboard
open fun startTrackingParticipantsLocations(    @NonNull users: Array<String>,     refreshInterval: Int,     @Nullable callback: StartTrackingParticipantsCallback)
Start tracking other users' locations
Link copied to clipboard
open fun stopTrackingDeviceLocation(@NonNull context: Context, @Nullable listener: TrackingDeviceLocationCallback)
Call this method to stop the location tracking
Link copied to clipboard
open fun stopTrackingParticipants()
Stop tracking other users's locations
Link copied to clipboard
open fun unregisterBeaconServiceListener(@NonNull listener: STWServiceListener)
Unregister the Beacon service event listener
Link copied to clipboard
open fun unregisterDispatcherStatusListener(@NonNull listener: STWDispatcherStatusListener)
Unregister for dispatcher status listener
Link copied to clipboard
open fun unregisterGeolocationChangesListener(@NonNull listener: STWGeolocationFeaturesListener)
Unregister for geolocation changes listener
Link copied to clipboard
open fun unregisterGeolocationServiceListener(@NonNull listener: STWServiceListener)
Unregister the service event listener
Link copied to clipboard
open fun unregisterTrackingLocationListener(@NonNull listener: STWTrackingDeviceLocationListener)
Unregister the listener to not be notified by the location tracking events
Link copied to clipboard
open fun unregisterTrackingParticipantsService(@NonNull listener: STWTrackingParticipantsListener)
Unregister the tracking participant service
Link copied to clipboard
open fun updateUserLocation(    @NonNull context: Context,     @Nullable latitude: Double,     @Nullable longitude: Double,     @Nullable time: Long,     @Nullable address: String)
Call this method to update the user location in the database