public abstract class

InteractiveRequest

extends Object
implements InteractiveAPI InteractiveListener<T, U, V>
java.lang.Object
   ↳ com.amazon.identity.auth.device.interactive.InteractiveRequest<T extends com.amazon.identity.auth.device.interactive.InteractiveListener<S, U, V>, S, U, V>
Known Direct Subclasses

Class Overview

InteractiveRequest is the base class for creating concrete interactive (out-of-app) requests. Each interactive request should define as much of the configuration and options for an interactive API as desired. Requests are bound to their listeners in two ways:

  • The Java type that corresponds to the listener is specified as the generic type parameter T.
  • The request type, as returned by getRequestType(). If desired, the request type can be dynamic values, however they will are bounded by the same class types.

Interactive requests also expose several convenience methods for Login With Amazon-enabled SDKs with interactive workflows, including the ability to:

  • Assert that a corresponding listener for this request is registered on the request context, which is useful in scenarios where you may wish to finish the request before calling openWorkflow(InteractiveRequest, String, String, Bundle).
  • After the above assertion, directly call all listeners for this request by calling the InteractiveListener methods exposed on the request.
{@since 3.0 }

Summary

Nested Classes
class InteractiveRequest.Builder<W extends InteractiveRequest<?, ?, ?, ?>> The base builder object for interactive requests. 
Public Constructors
InteractiveRequest(RequestContext requestContext)
Interactive requests require that they are made from a specific RequestContext.
Public Methods
void assertListenerPresent()
This method only intended for use by Login With Amazon-enabled SDKs.
Context getContext()
Each interactive request must be made from some Android Context.
abstract Class<T> getListenerClass()
This method only intended for use by Login With Amazon-enabled SDKs.
RequestContext getRequestContext()
This API is intended only for use by Login With Amazon-enabled SDKs.
Bundle getRequestExtras()
This method only intended for use by Login With Amazon-enabled SDKs.
boolean needHookOnActivity()
Do not call this API, it is used internally by the SDK and may be subject to change without notice.
void onCancel(U cancellation)
This method only intended for use by Login With Amazon-enabled SDKs.
void onError(V error)
This method only intended for use by Login With Amazon-enabled SDKs.
void onRequestCancel(Context context, InteractiveRequestRecord request, WorkflowCancellation cancellation)
Do not call this API, it is used internally by the SDK and may be subject to change without notice.
void onRequestCompletion(Context context, InteractiveRequestRecord request, Uri uri)
Do not call this API, it is used internally by the SDK and may be subject to change without notice.
void onRequestError(Context context, InteractiveRequestRecord request, Exception e)
Do not call this API, it is used internally by the SDK and may be subject to change without notice.
void onSuccess(S result)
This method only intended for use by Login With Amazon-enabled SDKs.
void setRequestContext(RequestContext requestContext)
Do not call this API, it is used internally by the SDK.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.amazon.identity.auth.device.api.CancellableListener
From interface com.amazon.identity.auth.device.api.Listener
From interface com.amazon.identity.auth.device.interactive.InteractiveAPI
From interface com.amazon.identity.auth.device.interactive.InteractiveListener

Public Constructors

public InteractiveRequest (RequestContext requestContext)

Interactive requests require that they are made from a specific RequestContext.

Parameters
requestContext Required.

Public Methods

public void assertListenerPresent ()

This method only intended for use by Login With Amazon-enabled SDKs.

Convenience method to check if this request's RequestContext has a corresponding listener registered.

Throws
ListenerNotFoundException If there is no listener for this request registered.

public Context getContext ()

Each interactive request must be made from some Android Context.

Returns
  • The Android context this request originated from.

public abstract Class<T> getListenerClass ()

This method only intended for use by Login With Amazon-enabled SDKs.

Interactive requests must declare the type of their corresponding listener as the T type parameter and also must return that type's Class here in order to accommodate for Java's type erasure. They must be the same, otherwise the interactive request flow will fail.

Returns
  • The Class of the listener type T.

public RequestContext getRequestContext ()

This API is intended only for use by Login With Amazon-enabled SDKs.

Each interactive request must have a request context so that its listeners can be triggered.

Returns
  • The request context for this request.

public Bundle getRequestExtras ()

This method only intended for use by Login With Amazon-enabled SDKs.

The Android lifecycle requires that instances of Activity and Fragment (where app developers will be making interactive requests from) may be destroyed and recreated at any time. This also means your InteractiveRequest subclass may get garbage collected and you could lose all data associated with the request object.

When an interactive request is started, this method will be called to associate the returned Bundle with the same request's response. When your request response is processed, LWA will return this bundle to your BaseWorkflowListener subclasses via getRequestExtras().

By default, this will return null.

Returns
  • A bundle containing your request's extra data to be passed back upon request completion, or null if no extras are to be passed.

public boolean needHookOnActivity ()

Do not call this API, it is used internally by the SDK and may be subject to change without notice.

public void onCancel (U cancellation)

This method only intended for use by Login With Amazon-enabled SDKs.

Call this method with a cancellation object to short-circuit an interactive request before it is started. All listeners registered to this request's RequestContext will have their onCancel called with the given cancellation object.

Parameters
cancellation The cancellation object to pass to the listeners.

public void onError (V error)

This method only intended for use by Login With Amazon-enabled SDKs.

Call this method with an error to short-circuit an interactive request before it is started. All listeners registered to this request's RequestContext will have their onError called with the given error.

Parameters
error The error to pass to the listeners.

public void onRequestCancel (Context context, InteractiveRequestRecord request, WorkflowCancellation cancellation)

Do not call this API, it is used internally by the SDK and may be subject to change without notice.

public void onRequestCompletion (Context context, InteractiveRequestRecord request, Uri uri)

Do not call this API, it is used internally by the SDK and may be subject to change without notice.

public void onRequestError (Context context, InteractiveRequestRecord request, Exception e)

Do not call this API, it is used internally by the SDK and may be subject to change without notice.

public void onSuccess (S result)

This method only intended for use by Login With Amazon-enabled SDKs.

Call this method with a result to short-circuit an interactive request before it is started. All listeners registered to this request's RequestContext will have their onSuccess called with the given result.

Parameters
result The result object to pass to the listeners.

public void setRequestContext (RequestContext requestContext)

Do not call this API, it is used internally by the SDK.

Updates the request's RequestContext. This is only necessary to do when the request source may have been recreated by the Android activity lifecycle.

Parameters
requestContext The new request context for this request.