public class

UALocationManager

extends AirshipComponent
java.lang.Object
   ↳ com.urbanairship.AirshipComponent
     ↳ com.urbanairship.location.UALocationManager

Class Overview

High level interface for interacting with location.

Summary

Public Methods
void addLocationListener(LocationListener listener)
Adds a listener for locations updates.
LocationRequestOptions getLocationRequestOptions()
Gets the location request options for continuous updates.
boolean isBackgroundLocationAllowed()
Checks if continuous location updates are allowed to continue when the application is in the background.
boolean isLocationUpdatesEnabled()
Checks if continuous location updates is enabled or not.
void removeLocationListener(LocationListener listener)
Removes location update listener.
Cancelable requestSingleLocation()
Records a single location using either the foreground request options or the background request options depending on the application's state.
Cancelable requestSingleLocation(LocationCallback locationCallback)
Records a single location using either the foreground request options or the background request options depending on the application's state.
Cancelable requestSingleLocation(LocationCallback locationCallback, LocationRequestOptions requestOptions)
Records a single location using custom location request options.
void setBackgroundLocationAllowed(boolean enabled)
Enable or disable allowing continuous updates to continue in the background.
void setLocationRequestOptions(LocationRequestOptions options)
Sets the location request options for continuous updates.
void setLocationUpdatesEnabled(boolean enabled)
Enable or disable continuous location updates.
Protected Methods
void init()
Initialize the manager.
void tearDown()
Tear down the manager.
[Expand]
Inherited Methods
From class com.urbanairship.AirshipComponent
From class java.lang.Object

Public Methods

public void addLocationListener (LocationListener listener)

Adds a listener for locations updates. The listener will only be notified of continuous location updates, not single location requests.

Parameters
listener A location listener.

public LocationRequestOptions getLocationRequestOptions ()

Gets the location request options for continuous updates. If no options have been set, it will default to createDefaultOptions().

Returns
  • The continuous location request options.

public boolean isBackgroundLocationAllowed ()

Checks if continuous location updates are allowed to continue when the application is in the background.

Returns
  • true if continuous location update are allowed, otherwise false.

public boolean isLocationUpdatesEnabled ()

Checks if continuous location updates is enabled or not.

Features that depend on analytics being enabled may not work properly if it's disabled (reports, region triggers, location segmentation, push to local time).

Returns
  • true if location updates are enabled, otherwise false.

public void removeLocationListener (LocationListener listener)

Removes location update listener.

Parameters
listener A location listener.

public Cancelable requestSingleLocation ()

Records a single location using either the foreground request options or the background request options depending on the application's state.

The request may fail due to insufficient permissions.

Returns
  • A cancelable object that can be used to cancel the request.

public Cancelable requestSingleLocation (LocationCallback locationCallback)

Records a single location using either the foreground request options or the background request options depending on the application's state.

Parameters
locationCallback Callback with the location. The result may return a null location if the request is unable to be made due to insufficient permissions.
Returns
  • A cancelable object that can be used to cancel the request.

public Cancelable requestSingleLocation (LocationCallback locationCallback, LocationRequestOptions requestOptions)

Records a single location using custom location request options.

Parameters
locationCallback Callback with the location. The result may return a null location or empty Cancelable request if the request is unable to be made due to insufficient permissions.
requestOptions The location request options.
Returns
  • A cancelable object that can be used to cancel the request.
Throws
IllegalArgumentException if the requestOptions is null.

public void setBackgroundLocationAllowed (boolean enabled)

Enable or disable allowing continuous updates to continue in the background.

Parameters
enabled If background updates are allowed in the background or not.

public void setLocationRequestOptions (LocationRequestOptions options)

Sets the location request options for continuous updates.

Parameters
options The location request options, or null to reset the options to the default settings.

public void setLocationUpdatesEnabled (boolean enabled)

Enable or disable continuous location updates.

Features that depend on analytics being enabled may not work properly if it's disabled (reports, region triggers, location segmentation, push to local time).

Parameters
enabled If location updates should be enabled or not.

Protected Methods

protected void init ()

Initialize the manager. Called in UAirship during takeoff.

protected void tearDown ()

Tear down the manager. Called in UAirship during land.