public class

AirshipLocationManager

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

Class Overview

High level interface for interacting with location.

Summary

[Expand]
Inherited Fields
From class com.urbanairship.AirshipComponent
Public Methods
void addLocationListener(LocationListener listener)
Adds a listener for locations updates.
LocationRequestOptions getLocationRequestOptions()
Gets the location request options for continuous updates.
boolean isBackgroundLocationAllowed()
boolean isLocationUpdatesEnabled()
boolean isOptIn()
void recordLocation(Location location, LocationRequestOptions options, int updateType)
This method is deprecated. Airship no longer provides historic location support.
void removeLocationListener(LocationListener listener)
Removes location update listener.
PendingResult<Location> requestSingleLocation()
Records a single location using either the foreground request options or the background request options depending on the application's state.
PendingResult<Location> requestSingleLocation(LocationRequestOptions requestOptions)
Records a single location using custom location request options.
void setBackgroundLocationAllowed(boolean enabled)
void setLocationRequestOptions(LocationRequestOptions options)
Sets the location request options for continuous updates.
void setLocationUpdatesEnabled(boolean enabled)
static AirshipLocationManager shared()
Gets the shared location instance.
Protected Methods
void init()
Initialize the manager.
void tearDown()
Tear down the manager.
[Expand]
Inherited Methods
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 ()

public boolean isLocationUpdatesEnabled ()

public boolean isOptIn ()

public void recordLocation (Location location, LocationRequestOptions options, int updateType)

This method is deprecated.
Airship no longer provides historic location support.

Records a location.

Parameters
location The new location.
options The location request options.
updateType The update type.

public void removeLocationListener (LocationListener listener)

Removes location update listener.

Parameters
listener A location listener.

public PendingResult<Location> 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 PendingResult<Location> requestSingleLocation (LocationRequestOptions requestOptions)

Records a single location using custom location request options.

Parameters
requestOptions The location request options.
Returns
  • A cancelable object that can be used to cancel the request.

public void setBackgroundLocationAllowed (boolean enabled)

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)

public static AirshipLocationManager shared ()

Gets the shared location instance.

Returns
  • The shared location instance.

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.