java.lang.Object | |
↳ | com.amazon.identity.auth.device.api.workflow.RequestContext |
In order to support out-of-app interactive user experiences while accommodating for the Android application
lifecycle, the Login With Amazon SDK provides RequestContext
. It serves as a tie between the
interactive requests and listeners registered to handle their responses.
Using an interactive flow (such as authorization) requires the RequestContext
to be integrated
correctly. The following describes the integration for a single interactive request source, which is the fragment or
activity that your interactive request originates from:
RequestContext
instance variable in the originating fragment or activity.RequestContext
to create(Activity)
, passing in your activity or fragment.onCreate
(or onCreateView
if your listener will capture references to views).onResume()
within it.Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This API is intended only for use by Login With Amazon-enabled SDKs.
| |||||||||||
Factory method for
android.support.v4.app.FragmentActivity request sources. | |||||||||||
Factory method for
Context request sources. | |||||||||||
Factory method for
Activity request sources. | |||||||||||
Factory method for
android.support.v4.app.Fragment request sources. | |||||||||||
Factory method for
Fragment request sources. | |||||||||||
This API is intended only for use by Login With Amazon-enabled SDKs.
| |||||||||||
This API is intended only for use by Login With Amazon-enabled SDKs.
| |||||||||||
This API is intended only for use by Login With Amazon-enabled SDKs.
| |||||||||||
Override the
onResume of your activity or fragment and call this method within it. | |||||||||||
Do not call this API, it is used internally by the SDK and may be subject to change without notice.
| |||||||||||
Do not call this API, it is used internally by the SDK and may be subject to change without notice.
| |||||||||||
Adds the listener to the set of listeners that this request context can handle.
| |||||||||||
Removes a listener instance from the set of listeners this request can handle.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
This API is intended only for use by Login With Amazon-enabled SDKs.
This method throws a runtime exception if a given interactive API (such as InteractiveRequest
or
InteractiveListener
) has a corresponding listener present in the set of listeners. The exception
should be propagated to the application developer to indicate an invalid integration.
This is implicitly called when openWorkflow(InteractiveRequest, String, String, Bundle)
is called to ensure that there is a listener for a given interactive request. Before calling
openWorkflow
, it is useful for Login With Amazon-enabled SDKs to call this method before attempting
to access the listeners in the case of fail-fast or short-circuit scenarios.
api | A request or listener object that corresponds to the type of listener whose presence is being asserted. |
---|
ListenerNotFoundException | If a corresponding listener for the given api is not available in
the set of listeners maintained by this request context.
|
---|
Factory method for android.support.v4.app.FragmentActivity
request sources.
Your app must use the Android Support Library v4 in order to use this API.
This API is deprecated, please refer to create(Context)
activity | The source of your interactive request. |
---|
Factory method for Context
request sources.
Your app must use the Android Support Library v4 in order to use this API.
context | The context source of your interactive request. |
---|
Factory method for Activity
request sources.
This API is deprecated, please refer to create(Context)
activity | The source of your interactive request. |
---|
Factory method for android.support.v4.app.Fragment
request sources.
Your app must use the Android Support Library v4 in order to use this API.
fragment | The source of your interactive request. |
---|
Factory method for Fragment
request sources.
Your app must declare minSdkVersoin >= 11 in order to use this API.
fragment | The source of your interactive request. |
---|
This API is intended only for use by Login With Amazon-enabled SDKs.
As an app developer may register multiple listeners for any given type of interactive request, this method exposes a listener that is the aggregation of all listeners of a given type for convenience. The aggregated listeners will be executed in an undefined order.
request | The request with which it should retrieve the aggregate listener for. |
---|
ListenerNotFoundException | If no listeners were present for the given request .
|
---|
Context
that the request context is associated with.
This API is intended only for use by Login With Amazon-enabled SDKs.
Retrieves the set of listeners registered for a given interactive API, cast to a the given
listenerClass
.
api | The interactive API to get the listeners for. |
---|---|
listenerClass | The Class of listener that the listener should be cast to. |
ListenerNotFoundException |
---|
This API is intended only for use by Login With Amazon-enabled SDKs.
Do not call this API, it is used internally by the SDK and may be subject to change without notice. Indicate if the RequestContext needed to be hooked at host Activity/Fragment.
Override the onResume
of your activity or fragment and call this method within it.
This signals to the RequestContext
that it should execute listeners for interactive flows that have
finished. The listeners will be executed on a separate thread.
Do not call this API, it is used internally by the SDK and may be subject to change without notice.
This method notifies the request context that a given request has been started.
request | A record of the request being started. |
---|
Do not call this API, it is used internally by the SDK and may be subject to change without notice.
Executes all listeners for a given interactive response URI on a separate thread pool.
request | A record of the request whose response is getting handled. |
---|---|
uri | The completed interactive response as a URI. |
Adds the listener to the set of listeners that this request context can handle. This must be done in one of the Android "on create" lifecycle methods to ensure that the listeners are available if your activity or fragment is recreated.
listener | The callback for a request that the originating request source will make. |
---|
Removes a listener instance from the set of listeners this request can handle. Because listeners are anonymous, the same instance must be passed in for it to be removed.
listener | The same listener instance to be removed. |
---|