LocationManager
Reference guide for LocationManager class and methods provided by Tealium for Android (Kotlin).
Class: LocationManager
The LocationManager
class provides methods for gathering location data, creating and monitoring geofences. The following summarizes the commonly used methods of the LocationManager
class for Tealium Kotlin. For additional details, see the Location module.
Method | Description |
---|---|
addGeofence() |
Creates and adds a new GeofenceLocation to allGeofenceLocations |
allGeofenceNames() |
Returns a list of all GeofenceLocation names |
lastLocation() |
Returns last known location result for user’s device |
lastLocationLatitude() |
Returns latitude for last location result |
lastLocationLongitude() |
Returns longitude for last location result |
startLocationTracking() |
Starts location tracking based on desired accuracy and interval updates |
stopLocationTracking() |
Stops location tracking updates |
addGeofence()
Provides to ability to manually create and add geofences for monitoring.
tealiumInstance.location?.addGeofence(
"Tealium-HQ",
45.0, // latitude
100.0, // longitude
100, // radius
-1, // expiry duration
0, // loiter duration
true, // events triggered on entry of geofence
true) // events triggered on exit of geofence
Parameter | Type | Description | Example |
---|---|---|---|
name |
String |
Name of location | "Tealium-HQ" |
latitude |
Double |
Latitude of location | 45.0 |
longitude |
Double |
Longitude of location | 100.0 |
radius |
Int |
Radius in meters of geofence | 100 |
expireTime |
Int |
Sets expiration duration in milliseconds for geofence | -1 |
loiterTime |
Int |
Sets duration in milliseconds for time delay between entering and dwelling a geofence | 0 |
triggerEnter |
Boolean |
Enables events being triggered upon entering a geofence | true |
triggerExit |
Boolean |
Enables events being triggered upon exiting a geofence | true |
allGeofenceNames()
Returns a list of all geofence names to be observed.
tealiumInstance.location?.allGeofenceNames()
lastLocation()
Returns most recent location recorded for a user’s device or null
if location is not available.
val location = tealiumInstance.location?.lastLocation()
lastLocationLatitude()
Returns the latitude for the most recent location recorded for a user’s device.
val latitude = tealiumInstance.location?.lastLocationLatitude()
lastLocationLongitude()
Returns the longitude for the most recent location recorded for a user’s device.
val longitude = tealiumInstance.location?.lastLocationLongitude()
startLocationTracking()
Starts continuous location tracking, as well as sets desired accuracy and preferred interval in milliseconds for location updates. Enabling precise location and frequent location update intervals may be costly to battery consumption.
tealiumInstance.location?.startLocationTracking(true, 1000)
Parameter | Type | Description | Example |
---|---|---|---|
isHighAcuracy |
Boolean |
Set to ’true’ for high precision location tracking, or false for accuracy within 100 meters |
true |
updateInterval |
Int |
Interval in milliseconds for preferred location update frequency | 10000 |
stopLocationTracking()
Halts continuous location tracking updates.
tealiumInstance.location?.stopLocationTracking()
This page was last updated: January 7, 2023