Location Services

You can use Location Services to get the periodic location updates using GPS and/or network providers.

Features Requiring Location Updates

  • Distance and speed calculation for Time To Collision (TTC) alerts
  • Data collection using Observation library

Note

To protect user privacy, applications that use location services must request location permissions. Live Sense SDK verifies this permission by checking ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION in AndroidManifest.

Configuration Modes

The accuracy of the location updates can be set by the locationManagerObject.setLocationQuality() method.

// LSDLocationManager.java
public void setLocationQuality(LSDLocationQuality locationQuality);

There are two modes to request location updates. These modes are provided in the LSDLocationQuality enum class:

  • LOW_POWER_NETWORK - uses Network and Passive providers to determine the location of device. This mode is selected by default.
  • HIGH_ACCURACY_GPS - uses GPS and Network providers to determine the location of the device. Consumes more power and has higher accuracy due to use of GPS.

Usage

To set locationQuality to HIGH_ACCURACY_GPS, use the following steps:

LSDLocationManager locationManager = LSDLocationManager.getInstance();
locationManager.setLocationQuality(LSDLocationQuality.HIGH_ACCURACY_GPS);

Requesting Location and Speed Updates

To enable/disable callback for any changes in location, listener for geo-location needs to be registered/deregistered respectively.

Usage

// location listener object
private final LSDLocationListener lsdLocationListener = new LSDLocationListener() {
        @Override
        public void onLocationChange(Location location) {
          // Use location object to get coordinates, altitude etc.
        }

        @Override
        public void onSpeedChange(float currentSpeed) {
          // Utilize currentSpeed value in ttc calculation etc.
        }
    };

// location manager object
LSDLocationManager locationManager = LSDLocationManager.getInstance();

// Register listener
locationManager.addLocationListener(lsdLocationListener);

// Deregister listener
locationManager.removeLocationListener(lsdLocationListener);

// Deregister all listeners
locationManager.removeAllLocationListeners();

results matching ""

    No results matching ""