Location Based Services (Android) - AAD - Unit III
Location Based Services (Android) - AAD - Unit III
Location Based Services (Android) - AAD - Unit III
(Android)
SAM DHANA SEKAR S P
DEPARTMENT OF CS, RCAS
Introduction
android.location
Contains the framework API classes that define Android location-based and related services.
Interfaces
LocationListener - Used for receiving notifications from the LocationManager when the location has
changed.
Classes
Location - A data class representing a geographic location.
LocationManager - This class provides access to the system location services.
LocationProvider - An abstract superclass for location providers.
Location Provider
Location Provider
A location provider provides periodic reports on the geographical location of the device.
Each provider has a set of criteria under which it may be used;
GPS_PROVIDER - require GPS hardware and visibility to a number of satellites;
This provider determines location using satellites.
Depending on conditions, this provider may take a while to return a location fix.
Requires the permission Manifest.permission.ACCESS_FINE_LOCATION.
NETWORK_PROVIDER
require the use of the cellular radio, or access to a specific carrier's network, or to the internet.
Requires the permission Manifest.permission.ACCESS_COARSE_LOCATION.
Location - Class
double getAltitude()
Get the altitude if available.
double getLatitude()
Get the latitude, in degrees.
double getLongitude()
Get the longitude, in degrees.
String getProvider()
Returns the name of the provider that generated this fix.
LocationListener - interface
Used for receiving notifications from the LocationManager when the location has changed.
Following methods are called if the LocationListener has been registered with the location manager
service using the
LocationManager.requestLocationUpdates(String, long, float, LocationListener) method.
abstract void onLocationChanged(Location location) - Called when the location has changed.
abstract void onProviderDisabled(String provider) - Called when the provider is disabled by the user.
abstract void onProviderEnabled(String provider) - Called when the provider is enabled by the user.
abstract void onStatusChanged(String provider, int status, Bundle extras)
LocationManager
This class provides access to the system location services. These services allow applications to
obtain periodic updates of the device's geographical location
methods
boolean isLocationEnabled()
Returns the current enabled/disabled state of location.