android-components / mozilla.components.service.location / MozillaLocationService

MozillaLocationService

class MozillaLocationService : LocationService (source)

The Mozilla Location Service (MLS) is an open service which lets devices determine their location based on network infrastructure like Bluetooth beacons, cell towers and WiFi access points.

  • https://location.services.mozilla.com/
  • https://mozilla.github.io/ichnaea/api/index.html

Note: Accessing the Mozilla Location Service requires an API token: https://location.services.mozilla.com/contact

Parameters

client - The HTTP client that this MozillaLocationService should use for requests.

apiKey - The API key that is used to access the Mozilla location service.

serviceUrl - An optional URL override usually only needed for testing.

Constructors

Name Summary
<init> MozillaLocationService(context: <ERROR CLASS>, client: Client, apiKey: String, serviceUrl: String = GEOIP_SERVICE_URL)
The Mozilla Location Service (MLS) is an open service which lets devices determine their location based on network infrastructure like Bluetooth beacons, cell towers and WiFi access points.

Functions

Name Summary
fetchRegion suspend fun fetchRegion(readFromCache: Boolean): Region?
Determines the current LocationService.Region based on the IP address used to access the service.
hasRegionCached fun hasRegionCached(): Boolean
Get if there is already a cached region. This does not guarantee we have the current actual region but only the last value which may be obsolete at this time.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.