public class

ActionRunRequest

extends Object
java.lang.Object
   ↳ com.urbanairship.actions.ActionRunRequest

Class Overview

ActionRunRequests provides a fluent API for running Actions.

If an action entails a UI interaction, shouldRunOnMainThread() will be overridden to return true so that the action runs on the UI thread when triggered asynchronously. If called by the UI thread, the action will run immediately, otherwise it will be posted to the main thread's looper. All other actions will run on their own thread. If the async run is triggered on the UI thread or a thread with a prepared looper, the optional ActionCompletionCallback will be executed on the calling thread by sending a message to the calling thread's handler. If the calling thread does not have a prepared looper, the callback will be executed on the main thread.

Synchronous runs will block, and should never be called on the UI thread. It should only be used when executing actions in a separate thread, or as a convenient way of running actions from another action.

Summary

Public Methods
static ActionRunRequest createRequest(String actionName)
Creates an action run request.
static ActionRunRequest createRequest(String actionName, ActionRegistry registry)
Creates an action run request.
static ActionRunRequest createRequest(Action action)
Creates an action run request.
void run()
Executes the action asynchronously.
void run(ActionCompletionCallback callback)
Executes the action asynchronously with a callback.
void run(Looper looper, ActionCompletionCallback callback)
Executes the action asynchronously with a callback.
ActionResult runSync()
Executes the action synchronously.
ActionRunRequest setMetadata(Bundle metadata)
Sets the action argument's metadata.
ActionRunRequest setSituation(int situation)
Sets the situation.
ActionRunRequest setValue(ActionValue actionValue)
Sets the action argument's value.
ActionRunRequest setValue(Object object)
Sets the action arguments value.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static ActionRunRequest createRequest (String actionName)

Creates an action run request. The action will not be run until running the request.

Parameters
actionName The action name in the registry.
Returns
  • An action run request.

public static ActionRunRequest createRequest (String actionName, ActionRegistry registry)

Creates an action run request. The action will not be run until running the request.

Parameters
actionName The action name in the registry.
registry Optional - The action registry to look up the action. If null, the registry from getActionRegistry() will be used.
Returns
  • An action run request.

public static ActionRunRequest createRequest (Action action)

Creates an action run request. The action will not be run until running the request.

Parameters
action The action to run.
Returns
  • An action run request.
Throws
IllegalArgumentException if the action is null.

public void run ()

Executes the action asynchronously.

public void run (ActionCompletionCallback callback)

Executes the action asynchronously with a callback.

Parameters
callback The action completion callback.

public void run (Looper looper, ActionCompletionCallback callback)

Executes the action asynchronously with a callback.

Parameters
looper A Looper object whose message queue will be used for the callback, or null to make callbacks on the calling thread or main thread if the current thread does not have a looper associated with it.
callback The action completion callback.

public ActionResult runSync ()

Executes the action synchronously.

Returns
  • The action's result.

public ActionRunRequest setMetadata (Bundle metadata)

Sets the action argument's metadata.

Parameters
metadata The action argument's metadata.
Returns
  • The request object.

public ActionRunRequest setSituation (int situation)

Sets the situation.

Parameters
situation The action argument's situation.
Returns
  • The request object.

public ActionRunRequest setValue (ActionValue actionValue)

Sets the action argument's value.

Parameters
actionValue The action argument's value.
Returns
  • The request object.

public ActionRunRequest setValue (Object object)

Sets the action arguments value. The object will automatically be wrapped as a ActionValue and throw an illegal argument exception if its an invalid value.

Parameters
object The action arguments as an object.
Returns
  • The request object.
Throws
IllegalArgumentException if the object is unable to be wrapped in an ActionValue.