Present Paywall Builder paywalls in Observer mode in Android SDK

If you’ve created a flow or paywall using the Flow Builder or Paywall Builder, you don’t need to worry about rendering it in your mobile app code to display it to the user. Such a flow or paywall contains both what should be shown within it and how it should be shown.

This section refers to Observer mode only. If you do not work in the Observer mode, refer to the Android - Present flows & paywalls topic instead.

Before you start presenting flows (Click to Expand)
  1. Set up initial integration of Adapty with the Google Play.
  2. Install and configure Adapty SDK. Make sure to set the observerMode parameter to true. Refer to our framework-specific instructions for Android.
  3. Create products in the Adapty Dashboard.
  4. Configure flows or paywalls in the builders and assign products to them.
  5. Create placements and assign your flows or paywalls to them in the Adapty Dashboard.
  6. Fetch flows and their configuration in your mobile app code.

  1. Implement the AdaptyUiObserverModeHandler.

The onPurchaseInitiated event will inform you that the user has initiated a purchase. You can trigger your custom purchase flow in response to this callback:

To handle restores in Observer mode, override getRestoreHandler(). By default it returns null, which uses Adapty’s built-in Adapty.restorePurchases() flow. To provide your own restore implementation:

Remember to invoke the following callbacks to notify AdaptyUI about the purchase or restore process. This is necessary for proper flow behavior, such as showing the loader:

CallbackDescription
onStartPurchase()The callback should be invoked to notify AdaptyUI that the purchase is started.
onFinishPurchase()The callback should be invoked to notify AdaptyUI that the purchase is finished.
onStartRestore()Optional. The callback can be invoked to notify AdaptyUI that the restore is started.
onFinishRestore()Optional. The callback can be invoked to notify AdaptyUI that the restore is finished.
  1. In order to display the visual flow on the device screen, you must first configure it.

Request parameters:

ParameterPresenceDescription
flowConfigurationrequiredSupply an AdaptyUI.FlowConfiguration object containing visual details of the flow. Use the AdaptyUI.getFlowConfiguration(flow) method to load it. Refer to Fetch the view configuration topic for more details.
productsoptionalProvide an array of AdaptyPaywallProduct to optimize the display timing of products on the screen. If null is passed, AdaptyUI will automatically fetch the required products.
eventListeneroptionalProvide an AdaptyFlowEventListener to observe flow events. Extending AdaptyFlowDefaultEventListener is recommended for ease of use. Refer to Handle flow & paywall events topic for more details.
insetsoptionalInsets are the spaces around the flow that prevent tapable elements from getting hidden behind system bars. Default: Unspecified, which lets Adapty adjust the insets automatically. See Change flow insets.
customAssetsoptionalPass an AdaptyCustomAssets object to replace images and videos in your flow or paywall at runtime. Refer to Customize assets for more details.
tagResolveroptionalUse AdaptyUiTagResolver to resolve custom tags within the flow text. This resolver takes a tag parameter and resolves it to a corresponding string. Refer to Custom tags in Paywall Builder topic for more details.
observerModeHandlerrequired for Observer modeThe AdaptyUiObserverModeHandler you’ve implemented in the previous step.

Don’t forget to associate paywalls to purchase transactions. Otherwise, Adapty will not determine the source flow of the purchase.