public class LocationManager extends java.lang.Object implements android.location.LocationListener, LifeCycle
LocationManager provides the user location. Usage example:
LocationManager manager = LocationManager.getInstance(activity);
manager.addMyLocationChangedListener(new LocationManager.MyLocationChangedListener() {
@Override
public void onMyLocationChanged(@NonNull LatLng latLng) {
...
}
});
Don't forget call LifeCycle methods: onCreate(), onResume(), onPause(), onDestroy(), onLowMemory()
Copyright (c) 2017 Nexusgeographics All rights reserved.
| Modifier and Type | Class and Description |
|---|---|
static interface |
LocationManager.MyLocationChangedListener |
| Modifier and Type | Field and Description |
|---|---|
static int |
AVAILABLE |
static int |
OUT_OF_SERVICE |
static int |
TEMPORARILY_UNAVAILABLE |
| Modifier and Type | Method and Description |
|---|---|
void |
addMyLocationChangedListener(LocationManager.MyLocationChangedListener listener) |
static LocationManager |
getInstance(android.app.Activity activity)
Gets location manager instance
|
LatLng |
getMyLocation()
Gets the user location.
|
void |
onCreate(android.os.Bundle savedInstanceState)
On create.
|
void |
onDestroy()
On destroy.
|
void |
onLocationChanged(android.location.Location location)
Called when the location has changed.
|
void |
onLowMemory()
On low memory.
|
void |
onPause()
On pause.
|
void |
onProviderDisabled(java.lang.String provider)
Called when the provider is disabled by the user.
|
void |
onProviderEnabled(java.lang.String provider)
Called when the provider is enabled by the user.
|
void |
onResume()
On resume.
|
void |
onStatusChanged(java.lang.String provider,
int status,
android.os.Bundle extras)
Called when the provider status changes.
|
void |
removeMyLocationChangedListener() |
public static final int AVAILABLE
public static final int OUT_OF_SERVICE
public static final int TEMPORARILY_UNAVAILABLE
public static LocationManager getInstance(android.app.Activity activity)
activity - The activitypublic void onCreate(android.os.Bundle savedInstanceState)
LifeCyclepublic void onResume()
LifeCyclepublic void onPause()
LifeCyclepublic void onDestroy()
LifeCyclepublic void onLowMemory()
LifeCycleonLowMemory in interface LifeCyclepublic void onStatusChanged(java.lang.String provider,
int status,
android.os.Bundle extras)
onStatusChanged in interface android.location.LocationListenerprovider - the name of the location provider associated with this update.status - OUT_OF_SERVICE if the provider is out of service, and this is not expected to change in the near future; TEMPORARILY_UNAVAILABLE if the provider is temporarily unavailable but is expected to be available shortly; and AVAILABLE if the provider is currently available.extras - an optional Bundle which will contain provider specific status variables.public void onProviderEnabled(java.lang.String provider)
onProviderEnabled in interface android.location.LocationListenerprovider - the name of the location provider associated with this update.public void onProviderDisabled(java.lang.String provider)
onProviderDisabled in interface android.location.LocationListenerprovider - the name of the location provider associated with this update.public final void onLocationChanged(android.location.Location location)
onLocationChanged in interface android.location.LocationListenerlocation - The new location, as a Location object.@Nullable public LatLng getMyLocation()
public void addMyLocationChangedListener(@NonNull
LocationManager.MyLocationChangedListener listener)
public void removeMyLocationChangedListener()