1/27
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Location-based services
use real-time location data from a mobile device or smartphone to provide information, entertainment, or security
Android location frameworks
android.location, com.google.android.gms.location
com.google.android.gms.location
simpler API, greater accuracy, more power efficient, more versatile
ACCESS_COARSE_LOCATION
to access locations provided by cell tower/Wi-Fi triangulation, always include this permission
ACCESS_FINE_LOCATION
to access locations provided by GPS, include only if app benefits from precise location access
Location
represents a geographic location sensed at a particular time, consists of a latitude, a longitude, a UTC timestamp
Address
represents an address as a set of strings describing a location
Geocoder
translates between locations and addresses
open fun getLatitude(): Double
returns the latitude of this location in degrees
open fun getLongitude(): Double
returns the longitude of this location in degrees
open fun getTime(): Long
returns the Unix epoch time of this location in milliseconds since
January 1, 1970
open fun bearingTo(dest: Location): Float
returns the approximate bearing in degrees east of true north
open fun distanceTo(Location dest): Float
returns the approximate distance in meters between this location
and the given location
open fun getAltitude(): Double
returns the altitude of this location in meters
open fun getBearing(): Float
returns the bearing at the time of this location in degrees
open fun getSpeed(): Float
returns the speed at the time of this location in meters/second
open fun getExtras(): Bundle?
returns an optional bundle of additional information associated
with this location
LocationServices
main entry point for location services integration
FusedLocationProviderClient
main entry point for interacting with the fused location provider
LocationRequest
contains quality-of-service parameters for requests to the fused
location provider
LocationCallback
used for receiving notifications from the fused location provider
fused location provider
combines different signals to provide location information while optimizing the device’s use of battery power, r manages the underlying location technologies, such as GPS and Wi-Fi, and provides a simple API that can be used to specify the required quality of service
getFusedLocationProviderClient()
can be used to obtain a reference to a FusedLocationProviderClient object
getLastLocation()
gets a location estimate more quickly and minimizes battery usage, but the location information might be out of date if no other clients have actively used location recently
getCurrentLocation()
gets a fresher, more accurate location more consistently.
Geocoding
the process of transforming a street address or other description of a location into a (latitude, longitude) coordinate
Reverse geocoding
the process of transforming a (latitude, longitude) coordinate into a street address
Geocoder
handles geocoding and reverse geocoding, requires a backend service that is not included in the core android framework.