java.lang.Object | |
↳ | com.urbanairship.Autopilot |
Autopilot allows UAirship.takeOff to be called without overriding the Application class. Typically, UAirship.takeOff must be called in Application.onCreate() so that the 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" />
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. | ||||||||||
boolean |
isReady(Context context)
Called before
automaticTakeOff(Context) to make sure Autopilot is ready to takeOff. | ||||||||||
void |
onAirshipReady(UAirship airship)
Called before the airship instance is returned in
shared() . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.urbanairship.UAirship.OnReadyCallback
|
The name of the AndroidManifest meta-data element used to hold the fully qualified class name of the application's Autopilot implementation.
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
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).
context | The application context. |
---|
true
to allow early takeOff, otherwise false
.
Starts the auto pilot takeOff process.
application | The application. |
---|
Starts the auto pilot takeOff process.
context | The application 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.
airshipconfig.properties
file.
Called before automaticTakeOff(Context)
to make sure Autopilot is ready to takeOff.
Warning: If false
, takeOff will not be called. Any synchronous access to UAirship
will throw an exception.
context | The application context. |
---|
true
to allow takeOff, otherwise false
.
Called before the airship instance is returned in shared()
. Use this method
to perform any Airship customizations. This method is called on a background thread, but if airship
takes longer than 5 seconds to be ready it could cause ANRs within the application.
airship | The UAirship instance. |
---|