Skip to main content

Crate robius_location

Crate robius_location 

Source
Expand description

A library to access system location data.

§Linux

Uses the XDG Desktop Portal, falling back to GeoClue directly if the portal isn’t there (never after a portal denial). No setup needed on a normal desktop install; see the README for what minimal distros need. Both Access variants map to the same portal permission, and one-shot requests give up after 60 seconds.

Note: every Manager method blocks on D-Bus round trips. Usually milliseconds, but a wedged service can stall Manager::new for 45s and the rest for 30s (portal) or 45s (GeoClue), so keep them off your UI thread.

If the provider dies, you get Error::TemporarilyUnavailable and updates stop. The next call reconnects, so just retry. Nothing carries over though, so the user may be asked to authorize again.

§Android

On Android the following must be added to the manifest:

<manifest ... >
  <!-- Always include this permission -->
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

  <!-- Include only if your app benefits from precise location access. -->
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

As specified in the Android documentation.

§Minimum API level

The minimum supported Android API level is 26 (Android 8.0): the bundled Java helper is loaded via InMemoryDexClassLoader, which requires API 26. Newer location APIs (e.g. getCurrentLocation) are used only when the device supports them, with a fallback for older versions, so set minSdk to at least 26 in your app.

Structs§

Coordinates
Location
Data about the device’s current whereabouts.
Manager
A manager for dealing with location data and handling location updates.

Enums§

Access
The kind of location access.
Accuracy
The accuracy of the location data.
Error
An error that can occur when fetching the location.

Traits§

Handler
A handler that handles location events and errors.

Type Aliases§

Result