Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Native
Skip to main content

Interface ITaskRequestBuilder

interface ITaskRequestBuilder
Extends com.amazon.apmf.IStandard The ITaskRequestBuilder allows callers to encode execution parameters of a Task. A TaskRequest consists of the name of the Task handler to run, an unique id associated with the submission, zero or more constraint sets and an optional persistence flag.

Methods

requireDeviceIdle()

ITaskRequestBuilder* requireDeviceIdle()
Add a constraint which requires the device to be idle for the Task to be eligible for execution. Note that calling this method is optional.

Returns

ITaskRequestBuilder* An ITaskRequestBuilder instance that can be used for further calls.

requireInternet()

ITaskRequestBuilder* requireInternet()
Add a constraint which requires the device to be connected to the internet for the Task to be eligible for execution. Note that calling this method is optional.

Returns

ITaskRequestBuilder* An ITaskRequestBuilder instance that can be used for further calls.

requireReboot()

ITaskRequestBuilder* requireReboot()
Add a constraint which requires the device to be rebooted before the Task is eligible for execution. This constraint does not guarantee immediate execution after the device is rebooted, just sometime after. This constraint is incompatible with requireTime and requireMessaging. Only one of these constraints may be set in a Task Request to decide when a Task must be executed. If set with a repeating flag, each iteration will run at most once every boot. Note: Calling this method is optional.

Returns

ITaskRequestBuilder* An ITaskRequestBuilder instance that can be used for further calls.

requireTime()

ITaskRequestBuilder* requireTime(ITimeProperties* properties)
Add a time properties object that requires that the Task execute subject to time constraints. The constraint can be a combination of a delay or start time, an execution window and/ or a repetition interval. This constraint is incompatible with requireReboot and requireMessaging. Only one of these constraints may be set in a Task Request to decide when a Task must be executed.

Parameters

properties
ITimeProperties* — Required The time properties to associate with the Task Request. Note: Calling this method is optional.

Returns

ITaskRequestBuilder* An ITaskRequestBuilder instance that can be used for further calls.

requireMessaging()

ITaskRequestBuilder* requireMessaging(string messageUri)
Add a constraint that allows the Task to be triggered when a Message is sent. Currently, messages refer to both uri triggers sent from Event Manager and Message Router. This constraint may also be configured such that it is satisfied multiple times allowing the Task to be repeated. This constraint is incompatible with requireTime and requireReboot. Only one of these constraints may be set in a Task Request to decide when a Task must be repeated.

Parameters

messageUri
string — Required A string identifying the message Uri of interest. Indicate this constraint may be satisfied multiple times by setting repeating(). Note that payloads are not persisted across restarts or reboots.

Returns

ITaskRequestBuilder* An ITaskRequestBuilder instance that can be used for further calls.

retryPolicy()

ITaskRequestBuilder* retryPolicy(IRetryPolicy* retryPolicy)
Configure a retry policy for this Task. A user configured retry policy is used when the Task posts a temporary failure result. If the system is under resource pressure a running task may be interrupted. In such situations the Task Manager performs automatic retries even if a retry policy was not set. See IRetryPolicyBuilder for details. Note that calling this method is optional. Note that calling this method additional times will replace the previous policy.

Parameters

retryPolicy
IRetryPolicy* — Required A retry policy defining how system should act on failed runs of the Task.

Returns

ITaskRequestBuilder* An ITaskRequestBuilder instance that can be used for further calls.

persistAfterAppDeath()

ITaskRequestBuilder* persistAfterAppDeath()
Instruct the system that this Task needs to be run across app restarts or system reboot. Note that calling this method is optional. Note that Task Manager will automatically remove non-persistent Tasks (meaning if persist() is not called) when app process terminates for any reason.

Returns

ITaskRequestBuilder* An ITaskRequestBuilder instance that can be used for further calls.

data()

ITaskRequestBuilder* data(com.amazon.apmf.IStandard* attachment)
Attach a strongly typed input payload to the ITaskRequest. The payload may be any valid Omnikit Data Object.

Parameters

attachment
com.amazon.apmf.IStandard* — Required The Omnikit Data Object to attach to this request.

Returns

ITaskRequestBuilder* An ITaskRequestBuilder instance that can be used for further calls.

name()

ITaskRequestBuilder* name(string taskName)
Set the unique name of the task to which this result applies. If the name is not set, the task name is the system generated Uuid. Note that the submitted task name may be at most 32 bytes in size. Note that the name must be unique within an application package. Note that the name can be reused once a task is completed or cancelled.

Parameters

taskName
string — Required A unique task name to identify the task

Returns

ITaskRequestBuilder* An ITaskRequestBuilder instance that can be used for further calls.

Throws


repeating()

ITaskRequestBuilder* repeating()
Indicate that the task should be run again based on a constraint. This is only compatible with time or messaging constraints.

Returns

ITaskRequestBuilder* An ITaskRequestBuilder instance that can be used for further calls.

build()

ITaskRequest* build(string componentName)
Builds a TaskRequest with the set parameters.

Parameters

componentName
string — Required A string identifier of the Task handler to execute. Call this method after setting all parameters using the ‘set’ methods. Note that the componentName must be a lifecycle component identified in the manifest.

Returns

ITaskRequest* A TaskRequest instance to be given to TaskManager for submit(), update() etc.

Throws


Last modified on October 29, 2026