public interface ILocationManager
ILocationManager
interface. A location manager class can be obtained
by calling the following code:
MDApplication.getService(IMDApplication.LOCATION_MANAGER_SERVICE)
and
then casting the result to an ILocationManager.
PermissionsManager.requestPermissionFor()
as appropriate. Where methods have access to a LocationSettings
Object,
a decision will be made about whether to request permission for GENERAL or PRECISE location,
based on the requested power profile. In situations where a LocationSettings
Object is not available, only GENERAL permission is sought.Modifier and Type | Field and Description |
---|---|
static int |
ERROR_BAD_CONFIGURATION
The
LocationSettings given made it impossible to service this
request. |
static int |
ERROR_NO_HARDWARE
There is no hardware on this device capable of giving location data that
matches the set criteria required by the settings.
|
static int |
ERROR_NO_PERMISSIONS
Permission has not been given to do this.
|
static int |
ERROR_NO_PREVIOUS_DATA
There was no previous data available when calling
getLastKnownLocation() |
static int |
ERROR_TIME_OUT
The
getLocation() request timed out before location data became available. |
static int |
ERROR_UNKNOWN
A general error has occurred that cannot be categorised.
|
Modifier and Type | Method and Description |
---|---|
void |
allowUpdatesInBackground(boolean allowUpdates)
Pass true to enable location updates when the application is in background mode.
|
void |
beginLocationUpdates(ILocationWatcher watcher,
LocationSettings settings)
Being watching for location changes.
|
void |
getLastKnownLocation(ILocationWatcher watcher)
Get the last location known to the device.
|
void |
getLocation(long timeout,
ILocationWatcher watcher,
LocationSettings settings)
Attempt to get fresh location data.
|
boolean |
isLocationEnabled()
Check to see if Location services are enabled on this handset.
|
void |
stopLocationUpdates()
Stop watching for location changes.
|
static final int ERROR_UNKNOWN
static final int ERROR_NO_PERMISSIONS
static final int ERROR_NO_HARDWARE
static final int ERROR_BAD_CONFIGURATION
LocationSettings
given made it impossible to service this
request.static final int ERROR_TIME_OUT
getLocation()
request timed out before location data became available.static final int ERROR_NO_PREVIOUS_DATA
getLastKnownLocation()
void getLocation(long timeout, ILocationWatcher watcher, LocationSettings settings)
timeout
- A positive length of time in milliseconds that the request is allowed to run for. If
no location data is returned by this time, the request is abandoned and an ERROR_TIME_OUT
signal is sent.watcher
- the class that should be informed of the outcome of this request.settings
- The settings to apply to this request, if the location hardware is not already active.void getLastKnownLocation(ILocationWatcher watcher)
watcher
- The class that should be informed of the last known location. In
situations where the last location cannot be determined, an ERROR_NO_PREVIOUS_DATA
signal is sent.void beginLocationUpdates(ILocationWatcher watcher, LocationSettings settings)
LocationSettings
object. Only one ILocationWatcher
can watch for updates at a time;watcher
- The class that should be informed of the last known location.settings
- The settings to apply to this request.void stopLocationUpdates()
boolean isLocationEnabled()
void allowUpdatesInBackground(boolean allowUpdates)
allowUpdates
- - enables or disables updates in background.