public abstract class LocationManager extends Object
Modifier and Type | Field and Description |
---|---|
static int |
AVAILABLE |
static int |
OUT_OF_SERVICE |
static int |
TEMPORARILY_UNAVAILABLE |
Constructor and Description |
---|
LocationManager() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
bindListener()
Allows the implementation to track events
|
protected abstract void |
clearListener()
Allows the implementation to track events
|
abstract Location |
getCurrentLocation()
Gets the current Location of the device, in most cases this uses the GPS.
|
Location |
getCurrentLocationSync()
Returns the current location synchronously, this is useful if you just want
to know the location NOW and don't care about tracking location.
|
Location |
getCurrentLocationSync(long timeout)
Returns the current location synchronously, this is useful if you just want
to know the location NOW and don't care about tracking location.
|
abstract Location |
getLastKnownLocation()
Gets the last known Location of the device.
|
protected LocationListener |
getLocationListener()
Allows the implementation to notify the location listener of changes to location
|
static LocationManager |
getLocationManager()
Gets the LocationManager instance
|
int |
getStatus()
Gets the Manager status: AVAILABLE, OUT_OF_SERVICE or TEMPORARILY_UNAVAILABLE
|
boolean |
isGPSDetectionSupported()
Returns true if the platform is able to detect if the GPS is on or off.
|
boolean |
isGPSEnabled()
Returns GPS on/off state if isGPSDetectionSupported() returns true
|
void |
setLocationListener(LocationListener l)
Sets a LocationListener on the device, use this method if you need to be
updated on the device Locations rather then calling getCurrentLocation.
|
protected void |
setStatus(int status)
Allows the implentation to set the status of the location
|
public static final int AVAILABLE
public static final int OUT_OF_SERVICE
public static final int TEMPORARILY_UNAVAILABLE
public static LocationManager getLocationManager()
public int getStatus()
protected void setStatus(int status)
status
- the new statuspublic abstract Location getCurrentLocation() throws IOException
IOException
- if Location cannot be retrieve from the devicepublic Location getCurrentLocationSync()
public Location getCurrentLocationSync(long timeout)
timeout
- timeout in milliseconds or -1 to never timeoutpublic abstract Location getLastKnownLocation()
public void setLocationListener(LocationListener l)
l
- a LocationListener or null to stop the current listener
from getting updatesprotected LocationListener getLocationListener()
protected abstract void bindListener()
protected abstract void clearListener()
public boolean isGPSDetectionSupported()
public boolean isGPSEnabled()