public class

Autopilot

extends Object
implements UAirship.OnReadyCallback
java.lang.Object
   ↳ com.urbanairship.Autopilot

Class Overview

Autopilot allows UAirship.takeOff to be called without overriding the Application class. Typically, UAirship.takeOff must be called in Application.onCreate() so that the Urban Airship library is ready to handle incoming events before intents are delivered to any application components. Calling takeOff directly is the simplest integration, however some application frameworks do not provide a way to extend the Application class. Autopilot allows you to provide your bootstrapping code in a way that allows the library to lazily execute it.

Autopilot will be called before onCreate() on the main process. If this is too early for the application to handle takeOff, it can be delayed by overriding allowEarlyTakeOff(Context). If delayed or if the application uses multiple processes, automaticTakeOff(Context) must be called at all application entry points (i.e., in the onCreate() method of all registered Broadcast Receivers, Activities and Services).

The default AirshipConfigOptions will be created from the airshipconfig.properties file from the assets. To provide a different config, override createAirshipConfigOptions(Context).

The default Autopilot behavior will call takeOff and load airship config options from the airshipconfig.properties file in the assets directory. To use autopilot, add the following entry to the application block in the Application AndroidManifest.xml:

<meta-data android:name="com.urbanairship.autopilot"
           android:value="com.urbanairship.AutoPilot" /> 

Autopilot can be customized in order to load config from a different source or to customize the Airship instance when it is ready. To customize Autopilot, extend the class and override either allowEarlyTakeOff(Context), onAirshipReady(UAirship), or createAirshipConfigOptions(Context) methods. The class must be non-abstract, public, and it should only have a single public, no-argument constructor. Register the class by adding an entry to the application block of your manifest containing the fully qualified class name of your Autopilot implementation:

<meta-data android:name="com.urbanairship.autopilot"
           android:value="com.urbanairship.push.sample.SampleAutopilot" /> 

Summary

Constants
String AUTOPILOT_MANIFEST_KEY The name of the AndroidManifest meta-data element used to hold the fully qualified class name of the application's Autopilot implementation.
Public Constructors
Autopilot()
Public Methods
boolean allowEarlyTakeOff(Context context)
Checks if Autopilot is able to takeOff before onCreate().
synchronized static void automaticTakeOff(Application application)
Starts the auto pilot takeOff process.
static void automaticTakeOff(Context context)
Starts the auto pilot takeOff process.
AirshipConfigOptions createAirshipConfigOptions(Context context)
Implement this method to provide AirshipConfigOptions for takeOff.
void onAirshipReady(UAirship airship)
Called when UAirship is ready.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.urbanairship.UAirship.OnReadyCallback

Constants

public static final String AUTOPILOT_MANIFEST_KEY

The name of the AndroidManifest meta-data element used to hold the fully qualified class name of the application's Autopilot implementation.

Constant Value: "com.urbanairship.autopilot"

Public Constructors

public Autopilot ()

Public Methods

public boolean allowEarlyTakeOff (Context context)

Checks if Autopilot is able to takeOff before onCreate().

Early takeOff will only be called on the main process. Apps that use multiple processes need to make sure automaticTakeOff(Context) is called in any other processes that use Urban Airship. If early takeOff is disabled, automaticTakeOff(Context) must be called at all application entry points (i.e., in the onCreate() method of all registered Broadcast Receivers, Activities and Services).

Parameters
context The application context.
Returns
  • true to allow early takeOff, otherwise false.

public static synchronized void automaticTakeOff (Application application)

Starts the auto pilot takeOff process.

Parameters
application The application.

public static void automaticTakeOff (Context context)

Starts the auto pilot takeOff process.

Parameters
context The application context.

public AirshipConfigOptions createAirshipConfigOptions (Context context)

Implement this method to provide AirshipConfigOptions for takeOff. This method may return null if the config should be loaded asynchronously from the airshipconfig.properties file.

Returns
  • The launch options. If null, the options will be loaded from the airshipconfig.properties file.

public void onAirshipReady (UAirship airship)

Called when UAirship is ready.

Parameters
airship The UAirship instance.