public class LocationServices
extends java.lang.Object
LocationListener with addLocationListener(LocationListener) to receive location updates.LocationListener with removeLocationListener(LocationListener).Note: If registering a listener in your Activity.onResume() implementation, you should unregister it in Activity.onPause(). (You won't receive location updates when paused, and this will cut down on unnecessary system overhead). Do not unregister in Activity.onSaveInstanceState(), because this won't be called if the user moves back in the history stack.
| Modifier and Type | Method and Description |
|---|---|
void |
addLocationListener(LocationListener locationListener)
Registers a LocationListener to receive location updates
|
boolean |
areLocationPermissionsGranted()
Check status of Location Permissions
|
android.location.Location |
getLastLocation()
Last known location
|
static LocationServices |
getLocationServices(android.content.Context context)
Primary (singleton) access method for LocationServices
|
boolean |
isGPSEnabled()
Returns if the GPS sensor is currently enabled
|
void |
onLocationChanged(android.location.Location location)
Called when the location has changed.
|
boolean |
removeLocationListener(LocationListener locationListener)
Unregister a LocationListener to stop receiving location updates
|
void |
toggleGPS(boolean enableGPS)
Enabled / Disable GPS focused location tracking
|
public static LocationServices getLocationServices(android.content.Context context)
context - Contextpublic void toggleGPS(boolean enableGPS)
enableGPS - true if GPS is to be enabled, false if GPS is to be disabledpublic boolean isGPSEnabled()
public void onLocationChanged(android.location.Location location)
location - The updated locationpublic android.location.Location getLastLocation()
public void addLocationListener(LocationListener locationListener)
locationListener - LocationListenerpublic boolean removeLocationListener(LocationListener locationListener)
locationListener - LocationListener to removepublic boolean areLocationPermissionsGranted()