Package com.mapbox.mapboxsdk.location.engine

Types

Name Summary
AndroidLocationEngineImpl
open class AndroidLocationEngineImpl : LocationEngineImpl
A location engine that uses core android.location and has no external dependencies [https://developer.android.com/guide/topics/location/strategies](https://developer.android.com/guide/topics/location/strategies).
GoogleLocationEngineImpl
open class GoogleLocationEngineImpl : LocationEngineImpl
Wraps implementation of Fused Location Provider
LocationEngine
interface LocationEngine
Generic location engine interface wrapper for the location providers.
LocationEngineCallback
interface LocationEngineCallback<T>
Invoked for asynchronous notifications when new data from engine becomes available.
LocationEngineImpl
interface LocationEngineImpl<T>
Internal location engine implementation interface.
LocationEngineProvider
class LocationEngineProvider
The main entry point for location engine integration.
LocationEngineProxy
open class LocationEngineProxy<T> : LocationEngine
LocationEngineRequest
open class LocationEngineRequest
Data model that contains parameters for location engine requests.
LocationEngineResult
class LocationEngineResult
A wrapper class representing location result from the location engine.
MapboxFusedLocationEngineImpl
open class MapboxFusedLocationEngineImpl : AndroidLocationEngineImpl
Mapbox replacement for Google Play Services Fused Location Client Note: fusion will not work in background mode.
Utils
class Utils

AndroidLocationEngineImpl

open class AndroidLocationEngineImpl : LocationEngineImpl

A location engine that uses core android.location and has no external dependencies https://developer.android.com/guide/topics/location/strategies.html

Constructors

Name Summary
AndroidLocationEngineImpl open fun AndroidLocationEngineImpl(context: Context)

Types

Name Summary
AndroidLocationEngineCallbackTransport
class AndroidLocationEngineCallbackTransport : LocationListener

Functions

Name Summary
createListener
@NonNull()
open fun createListener(callback: LocationEngineCallback<LocationEngineResult>): LocationListener
@NonNull()
abstract fun createListener(callback: LocationEngineCallback<LocationEngineResult>): T
getCriteria
open fun getCriteria(priority: Int): Criteria
getLastLocation
open fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)
getLastLocationFor
open fun getLastLocationFor(provider: String): Location
removeLocationUpdates
open fun removeLocationUpdates(pendingIntent: PendingIntent)
open fun removeLocationUpdates(listener: LocationListener)
abstract fun removeLocationUpdates(listener: T)
requestLocationUpdates
open fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)
abstract fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)
open fun requestLocationUpdates(request: LocationEngineRequest, listener: LocationListener, looper: Looper)
abstract fun requestLocationUpdates(request: LocationEngineRequest, listener: T, looper: Looper)

Properties

Name Summary
currentProvider open val currentProvider: String
locationManager val locationManager: LocationManager

Inheritors

Name
MapboxFusedLocationEngineImpl

createListener

@NonNull()

open fun createListener(callback: LocationEngineCallback<LocationEngineResult>): LocationListener

currentProvider

open val currentProvider: String

getCriteria

open fun getCriteria(priority: Int): Criteria

getLastLocationFor

open fun getLastLocationFor(provider: String): Location

getLastLocation

open fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)

locationManager

val locationManager: LocationManager

removeLocationUpdates

open fun removeLocationUpdates(listener: LocationListener)
open fun removeLocationUpdates(pendingIntent: PendingIntent)

requestLocationUpdates

open fun requestLocationUpdates(request: LocationEngineRequest, listener: LocationListener, looper: Looper)
open fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)

AndroidLocationEngineCallbackTransport

class AndroidLocationEngineCallbackTransport : LocationListener

Constructors

Name Summary
AndroidLocationEngineCallbackTransport open fun AndroidLocationEngineCallbackTransport(callback: LocationEngineCallback<LocationEngineResult>)

Functions

Name Summary
onLocationChanged
abstract fun onLocationChanged(p: Location)
open fun onLocationChanged(location: Location)
onProviderDisabled
abstract fun onProviderDisabled(p: String)
open fun onProviderDisabled(s: String)
onProviderEnabled
abstract fun onProviderEnabled(p: String)
open fun onProviderEnabled(s: String)
onStatusChanged
abstract fun onStatusChanged(p: String, p1: Int, p2: Bundle)
open fun onStatusChanged(s: String, i: Int, bundle: Bundle)

onLocationChanged

open fun onLocationChanged(location: Location)

onProviderDisabled

open fun onProviderDisabled(s: String)

onProviderEnabled

open fun onProviderEnabled(s: String)

onStatusChanged

open fun onStatusChanged(s: String, i: Int, bundle: Bundle)

GoogleLocationEngineImpl

open class GoogleLocationEngineImpl : LocationEngineImpl

Wraps implementation of Fused Location Provider

Constructors

Name Summary
GoogleLocationEngineImpl open fun GoogleLocationEngineImpl(fusedLocationProviderClient: FusedLocationProviderClient)
GoogleLocationEngineImpl open fun GoogleLocationEngineImpl(context: Context)

Types

Name Summary
GoogleLastLocationEngineCallbackTransport
class GoogleLastLocationEngineCallbackTransport : OnSuccessListener , OnFailureListener

Functions

Name Summary
createListener
@NonNull()
open fun createListener(callback: LocationEngineCallback<LocationEngineResult>): LocationCallback
@NonNull()
abstract fun createListener(callback: LocationEngineCallback<LocationEngineResult>): T
getLastLocation
open fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)
removeLocationUpdates
open fun removeLocationUpdates(pendingIntent: PendingIntent)
open fun removeLocationUpdates(listener: LocationCallback)
abstract fun removeLocationUpdates(listener: T)
requestLocationUpdates
open fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)
abstract fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)
open fun requestLocationUpdates(request: LocationEngineRequest, listener: LocationCallback, looper: Looper)
abstract fun requestLocationUpdates(request: LocationEngineRequest, listener: T, looper: Looper)

createListener

@NonNull()

open fun createListener(callback: LocationEngineCallback<LocationEngineResult>): LocationCallback

getLastLocation

open fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)

removeLocationUpdates

open fun removeLocationUpdates(listener: LocationCallback)
open fun removeLocationUpdates(pendingIntent: PendingIntent)

requestLocationUpdates

open fun requestLocationUpdates(request: LocationEngineRequest, listener: LocationCallback, looper: Looper)
open fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)

GoogleLastLocationEngineCallbackTransport

class GoogleLastLocationEngineCallbackTransport : OnSuccessListener , OnFailureListener

Constructors

Name Summary
GoogleLastLocationEngineCallbackTransport open fun GoogleLastLocationEngineCallbackTransport(callback: LocationEngineCallback<LocationEngineResult>)

Functions

Name Summary
onFailure
abstract fun onFailure(p: Exception)
open fun onFailure(e: Exception)
onSuccess
abstract fun onSuccess(p: TResult)
open fun onSuccess(location: Location)

onFailure

open fun onFailure(e: Exception)

onSuccess

open fun onSuccess(location: Location)

LocationEngine

interface LocationEngine

Generic location engine interface wrapper for the location providers. Default providers bundled with Mapbox location library: Android location provider and Google Play Services fused location provider

Functions

Name Summary
getLastLocation
abstract fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)
Returns the most recent location currently available.
removeLocationUpdates
abstract fun removeLocationUpdates(pendingIntent: PendingIntent)
Removes location updates for the given pending intent.
abstract fun removeLocationUpdates(callback: LocationEngineCallback<LocationEngineResult>)
Removes location updates for the given location engine callback.
requestLocationUpdates
abstract fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)
Requests location updates with callback on the specified PendingIntent.
abstract fun requestLocationUpdates(request: LocationEngineRequest, callback: LocationEngineCallback<LocationEngineResult>, looper: Looper)
Requests location updates with a callback on the specified Looper thread.

Inheritors

Name
LocationEngineProxy

getLastLocation

abstract fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)

Returns the most recent location currently available.

If a location is not available, which should happen very rarely, null will be returned.

Parameters
Name Summary
callback
LocationEngineCallback for the location result LocationEngineResult.
   

Throws

Name Summary
java.lang.SecurityException
if permission is not granted to access location services.
   

removeLocationUpdates

abstract fun removeLocationUpdates(callback: LocationEngineCallback<LocationEngineResult>)

Removes location updates for the given location engine callback.

It is recommended to remove location requests when the activity is in a paused orstopped state, doing so helps battery performance.

Parameters
Name Summary
callback
LocationEngineCallback to remove.
   
   

abstract fun removeLocationUpdates(pendingIntent: PendingIntent)

Removes location updates for the given pending intent.

It is recommended to remove location requests when the activity is in a paused orstopped state, doing so helps battery performance.

Parameters
Name Summary
pendingIntent
PendingIntent to remove.
   
   

requestLocationUpdates

abstract fun requestLocationUpdates(request: LocationEngineRequest, callback: LocationEngineCallback<LocationEngineResult>, looper: Looper)

Requests location updates with a callback on the specified Looper thread.

Parameters
Name Summary
request
LocationEngineRequest for the updates.
callback
LocationEngineCallback for the location result LocationEngineResult.
looper
The Looper object whose message queue will be used to implement the callback mechanism,or null to invoke callbacks on the main thread.
   

Throws

Name Summary
java.lang.SecurityException
if permission is not granted to access location services.
   

abstract fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)

Requests location updates with callback on the specified PendingIntent.

Parameters
Name Summary
request
LocationEngineRequest for the updates.
pendingIntent
PendingIntent for the location result LocationEngineResult.
   

Throws

Name Summary
java.lang.SecurityException
if permission is not granted to access location services.
   

LocationEngineCallback

interface LocationEngineCallback<T>

Invoked for asynchronous notifications when new data from engine becomes available.

Parameters
Name Summary

Successful updated data type
   

Functions

Name Summary
onFailure
abstract fun onFailure(exception: Exception)
Invoked when engine exception occurs.
onSuccess
abstract fun onSuccess(result: T)
Invoked when new data available.

Inheritors

Name
LocationComponent
LocationComponent

onFailure

abstract fun onFailure(exception: Exception)

Invoked when engine exception occurs.

Parameters
Name Summary
exception
Exception
   
   

onSuccess

abstract fun onSuccess(result: T)

Invoked when new data available.

Parameters
Name Summary
result
updated data.
   
   

LocationEngineImpl

interface LocationEngineImpl<T>

Internal location engine implementation interface.

Parameters
Name Summary

location listener object type
   

Functions

Name Summary
createListener
@NonNull()
abstract fun createListener(callback: LocationEngineCallback<LocationEngineResult>): T
getLastLocation
abstract fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)
removeLocationUpdates
abstract fun removeLocationUpdates(listener: T)
abstract fun removeLocationUpdates(pendingIntent: PendingIntent)
requestLocationUpdates
abstract fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)
abstract fun requestLocationUpdates(request: LocationEngineRequest, listener: T, looper: Looper)

Inheritors

Name
AndroidLocationEngineImpl
GoogleLocationEngineImpl

createListener

@NonNull()

abstract fun createListener(callback: LocationEngineCallback<LocationEngineResult>): T

getLastLocation

abstract fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)

removeLocationUpdates

abstract fun removeLocationUpdates(listener: T)
abstract fun removeLocationUpdates(pendingIntent: PendingIntent)

requestLocationUpdates

abstract fun requestLocationUpdates(request: LocationEngineRequest, listener: T, looper: Looper)
abstract fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)

LocationEngineProvider

class LocationEngineProvider

The main entry point for location engine integration.

Functions

Name Summary
getBestLocationEngine
@NonNull()
open fun getBestLocationEngine(context: Context): LocationEngine
Returns instance to the best location engine, given the included libraries.

getBestLocationEngine

@NonNull()

open fun getBestLocationEngine(context: Context): LocationEngine

Returns instance to the best location engine, given the included libraries.

Return

a unique instance of LocationEngine every time method is called.

Parameters
Name Summary
context
Context.
   
   

LocationEngineProxy

open class LocationEngineProxy<T> : LocationEngine

Constructors

Name Summary
LocationEngineProxy open fun LocationEngineProxy(locationEngineImpl: LocationEngineImpl<T>)

Functions

Name Summary
getLastLocation
open fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)
Returns the most recent location currently available.
getListener
open fun getListener(callback: LocationEngineCallback<LocationEngineResult>): T
getListenersCount
open fun getListenersCount(): Int
removeListener
open fun removeListener(callback: LocationEngineCallback<LocationEngineResult>): T
removeLocationUpdates
open fun removeLocationUpdates(pendingIntent: PendingIntent)
Removes location updates for the given pending intent.
open fun removeLocationUpdates(callback: LocationEngineCallback<LocationEngineResult>)
Removes location updates for the given location engine callback.
requestLocationUpdates
abstract fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)
open fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)
Requests location updates with callback on the specified PendingIntent.
abstract fun requestLocationUpdates(request: LocationEngineRequest, callback: LocationEngineCallback<LocationEngineResult>, looper: Looper)
open fun requestLocationUpdates(request: LocationEngineRequest, callback: LocationEngineCallback<LocationEngineResult>, looper: Looper)
Requests location updates with a callback on the specified Looper thread.

getLastLocation

open fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)

Returns the most recent location currently available.

If a location is not available, which should happen very rarely, null will be returned.

Parameters
Name Summary
callback
LocationEngineCallback for the location result LocationEngineResult.
   

Throws

Name Summary
java.lang.SecurityException
if permission is not granted to access location services.
   

getListener

open fun getListener(callback: LocationEngineCallback<LocationEngineResult>): T

getListenersCount

open fun getListenersCount(): Int

removeListener

open fun removeListener(callback: LocationEngineCallback<LocationEngineResult>): T

removeLocationUpdates

open fun removeLocationUpdates(callback: LocationEngineCallback<LocationEngineResult>)

Removes location updates for the given location engine callback.

It is recommended to remove location requests when the activity is in a paused orstopped state, doing so helps battery performance.

Parameters
Name Summary
callback
LocationEngineCallback to remove.
   
   

open fun removeLocationUpdates(pendingIntent: PendingIntent)

Removes location updates for the given pending intent.

It is recommended to remove location requests when the activity is in a paused orstopped state, doing so helps battery performance.

Parameters
Name Summary
pendingIntent
PendingIntent to remove.
   
   

requestLocationUpdates

open fun requestLocationUpdates(request: LocationEngineRequest, callback: LocationEngineCallback<LocationEngineResult>, looper: Looper)

Requests location updates with a callback on the specified Looper thread.

Parameters
Name Summary
request
LocationEngineRequest for the updates.
callback
LocationEngineCallback for the location result LocationEngineResult.
looper
The Looper object whose message queue will be used to implement the callback mechanism,or null to invoke callbacks on the main thread.
   

Throws

Name Summary
java.lang.SecurityException
if permission is not granted to access location services.
   

open fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)

Requests location updates with callback on the specified PendingIntent.

Parameters
Name Summary
request
LocationEngineRequest for the updates.
pendingIntent
PendingIntent for the location result LocationEngineResult.
   

Throws

Name Summary
java.lang.SecurityException
if permission is not granted to access location services.
   

LocationEngineRequest

open class LocationEngineRequest

Data model that contains parameters for location engine requests.

Types

Name Summary
Builder
class Builder

Functions

Name Summary
equals
open fun equals(o: Any): Boolean
Compares this LocationEngineRequest to the specified object.
hashCode
open fun hashCode(): Int
Returns a hash code for this object.

Properties

Name Summary
displacement private val displacement: Float
fastestInterval private val fastestInterval: Long
interval private val interval: Long
maxWaitTime private val maxWaitTime: Long
priority private val priority: Int
PRIORITY_BALANCED_POWER_ACCURACY val PRIORITY_BALANCED_POWER_ACCURACY: IntUsed with setPriority to requestcoarse location that is battery optimized.
PRIORITY_HIGH_ACCURACY val PRIORITY_HIGH_ACCURACY: IntUsed with setPriority to requestthe most accurate location.
PRIORITY_LOW_POWER val PRIORITY_LOW_POWER: IntUsed with setPriority to requestcoarse ~ 10 km accuracy location.
PRIORITY_NO_POWER val PRIORITY_NO_POWER: IntUsed with setPriority to requestpassive location: no locations will be returned unless a different clienthas requested location updates.

PRIORITY_BALANCED_POWER_ACCURACY

val PRIORITY_BALANCED_POWER_ACCURACY: Int

Used with setPriority to requestcoarse location that is battery optimized.

PRIORITY_HIGH_ACCURACY

val PRIORITY_HIGH_ACCURACY: Int

Used with setPriority to requestthe most accurate location.

PRIORITY_LOW_POWER

val PRIORITY_LOW_POWER: Int

Used with setPriority to requestcoarse ~ 10 km accuracy location.

PRIORITY_NO_POWER

val PRIORITY_NO_POWER: Int

Used with setPriority to requestpassive location: no locations will be returned unless a different clienthas requested location updates.

displacement

private val displacement: Float

equals

open fun equals(o: Any): Boolean

Compares this LocationEngineRequest to the specified object.

Return

true when the type and values are equal, false otherwise.

Parameters
Name Summary
o
locationEngineRequest to compare to.
   
   

fastestInterval

private val fastestInterval: Long

hashCode

open fun hashCode(): Int

Returns a hash code for this object.

Return

integer hash of the values.

interval

private val interval: Long

maxWaitTime

private val maxWaitTime: Long

priority

private val priority: Int

Builder

class Builder

Constructors

Name Summary
Builder open fun Builder(interval: Long)Default builder constructor.

Functions

Name Summary
build
open fun build(): LocationEngineRequest
Builds request object.

Properties

Name Summary
displacement private open var displacement: Float
fastestInterval private open var fastestInterval: Long
maxWaitTime private open var maxWaitTime: Long
priority private open var priority: Int

build

open fun build(): LocationEngineRequest

Builds request object.

Return

instance of location request.

displacement

private open var displacement: Float

fastestInterval

private open var fastestInterval: Long

maxWaitTime

private open var maxWaitTime: Long

priority

private open var priority: Int

LocationEngineResult

class LocationEngineResult

A wrapper class representing location result from the location engine.

TODO: Override default equals(), hashCode() and toString()

Functions

Name Summary
create
@NonNull()
open fun create(location: Location): LocationEngineResult
Creates LocationEngineResult instance for location.
@NonNull()
open fun create(locations: List): [LocationEngineResult](#locationengineresult)
Creates [LocationEngineResult](#locationengineresult) instance for given list of locations.
extractResult
@Nullable()
open fun extractResult(intent: Intent): LocationEngineResult
Extracts location result from intent object
getLastLocation
@Nullable()
open fun getLastLocation(): Location
Returns most recent location available in this result.

Properties

Name Summary
locations private val locations: List

create

@NonNull()

open fun create(location: Location): LocationEngineResult

Creates LocationEngineResult instance for location.

Return

instance of the new location result.

Parameters
Name Summary
location
default location added to the result.
   
   

@NonNull()

open fun create(locations: List): [LocationEngineResult](#locationengineresult)

Creates LocationEngineResult instance for given list of locations.

Return

instance of the new location result.

Parameters
Name Summary
locations
list of locations.
   
   

extractResult

@Nullable()

open fun extractResult(intent: Intent): LocationEngineResult

Extracts location result from intent object

Return

location result.

Parameters
Name Summary
intent
valid intent object
   
   

getLastLocation

@Nullable()

open fun getLastLocation(): Location

Returns most recent location available in this result.

Return

the most recent location Location or null.

locations

private val locations: List

MapboxFusedLocationEngineImpl

open class MapboxFusedLocationEngineImpl : AndroidLocationEngineImpl

Mapbox replacement for Google Play Services Fused Location Client

Note: fusion will not work in background mode.

Constructors

Name Summary
MapboxFusedLocationEngineImpl open fun MapboxFusedLocationEngineImpl(context: Context)

Functions

Name Summary
createListener
@NonNull()
abstract fun createListener(callback: LocationEngineCallback<LocationEngineResult>): T
@NonNull()
open fun createListener(callback: LocationEngineCallback<LocationEngineResult>): LocationListener
getCriteria
open fun getCriteria(priority: Int): Criteria
getLastLocation
open fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)
getLastLocationFor
open fun getLastLocationFor(provider: String): Location
removeLocationUpdates
open fun removeLocationUpdates(pendingIntent: PendingIntent)
open fun removeLocationUpdates(listener: LocationListener)
abstract fun removeLocationUpdates(listener: T)
requestLocationUpdates
abstract fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)
open fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)
abstract fun requestLocationUpdates(request: LocationEngineRequest, listener: T, looper: Looper)
open fun requestLocationUpdates(request: LocationEngineRequest, listener: LocationListener, looper: Looper)

createListener

@NonNull()

open fun createListener(callback: LocationEngineCallback<LocationEngineResult>): LocationListener

getLastLocation

open fun getLastLocation(callback: LocationEngineCallback<LocationEngineResult>)

requestLocationUpdates

open fun requestLocationUpdates(request: LocationEngineRequest, listener: LocationListener, looper: Looper)
open fun requestLocationUpdates(request: LocationEngineRequest, pendingIntent: PendingIntent)

Utils

class Utils

Functions

Name Summary
checkNotNull
open fun <T> checkNotNull(reference: T, message: String): T
Ensures that an object reference passed as a parameter to the calling method is not null.
isBetterLocation
open fun isBetterLocation(location: Location, currentBestLocation: Location): Boolean
Determines whether one Location reading is better than the current Location fix(c) https://developer.android.
isOnClasspath
open fun isOnClasspath(className: String): Boolean
Checks if class is on class path

checkNotNull

open fun <T> checkNotNull(reference: T, message: String): T

Ensures that an object reference passed as a parameter to the calling method is not null.

Return

validated non-null reference.

Parameters
Name Summary
reference
object reference.
message
exception message to use if check fails.

object type.
   
   

isBetterLocation

open fun isBetterLocation(location: Location, currentBestLocation: Location): Boolean

Determines whether one Location reading is better than the current Location fix

(c) https://developer.android.com/guide/topics/location/strategies

Parameters
Name Summary
location
The new Location that you want to evaluate
currentBestLocation
The current Location fix, to which you want to compare the new one
   
   

isOnClasspath

open fun isOnClasspath(className: String): Boolean

Checks if class is on class path

Return

true if class in on class path, false otherwise.

Parameters
Name Summary
className
of the class to check.