Enable purchases with Flow Builder in Android SDK

To enable in-app purchases, you need to understand three key concepts:

  • Products – anything users can buy (subscriptions, consumables, lifetime access)
  • Flows – screen sequences that present products to users, built in the no-code Flow Builder. The SDK retrieves them via getFlow. If you’d rather build the UI in your own code, use a paywall instead — see Implement paywalls manually.
  • Placements – where and when you show flows in your app (like main, onboarding, settings). You attach flows to placements in the dashboard, then request them by placement ID in your code. This makes it easy to run A/B tests and show different flows to different users.

Adapty offers you three ways to enable purchases in your app. Select one of them depending on your app requirements:

ImplementationComplexityWhen to use
Adapty Flow Builder✅ EasyYou create a complete, purchase-ready flow in the no-code builder. Adapty automatically renders it and handles all the complex purchase flow, receipt validation, and subscription management behind the scenes.
Manually created paywalls🟡 MediumYou implement your paywall UI in your app code, but still get the flow object from Adapty to maintain flexibility in product offerings. See the guide.
Observer mode🔴 HardYou already have your own purchase handling infrastructure and want to keep using it. Note that the observer mode has its limitations in Adapty. See the article.

The steps below show how to implement a flow created in the Adapty Flow Builder.

If you’d rather build the paywall UI yourself, see Implement paywalls manually.

To display a flow created in the Adapty Flow Builder, in your app code, you only need to:

  1. Get the flow: Get it from Adapty.
  2. Display it and Adapty will handle purchases for you: Show the view in your app.
  3. Handle button actions: Associate user interactions with your app’s response to them. For example, open links or close the flow when users click buttons.

Before you start

Before you start, complete these steps:

  1. Connect your app to Google Play in the Adapty Dashboard.
  2. Create your products in Adapty.
  3. Create a flow and add products to it.
  4. Create a placement and add your flow to it.
  5. Install and activate the Adapty SDK in your app code. This guide uses Adapty Android SDK v4 APIs.

The fastest way to complete these steps is to follow the quickstart guide or create flows and placements using the Developer CLI.

1. Get the flow

Your flows are associated with placements configured in the dashboard. Placements allow you to run different flows for different audiences or to run A/B tests.

To get a flow created in the Adapty Flow Builder, you need to:

  1. Get the flow object by the placement ID using the getFlow method and check whether it has a view configuration.

  2. Get the view configuration using the getFlowConfiguration method. The view configuration contains the UI elements and styling needed to display the flow.

To get the view configuration, you must switch on the Show on device toggle in the Flow Builder. Otherwise, you will get an empty view configuration, and the flow won’t be displayed.

2. Display the flow

Now, when you have the flow configuration, it’s enough to add a few lines to display your flow.

In order to display the visual flow on the device screen, you must first configure it. To do this, call the method AdaptyUI.getFlowView() or create the AdaptyFlowView directly:

After the view has been successfully created, you can add it to the view hierarchy and display it on the screen of the device.

For more details on how to display a flow, see our guide.

3. Handle button actions

When users click buttons in the flow, the Android SDK automatically handles purchases, restoration, closing the flow, and opening links.

However, other buttons have custom or pre-defined IDs and require handling actions in your code. Or, you may want to override their default behavior.

For example, here is the default behavior for the close button. You don’t need to add it in the code, but here, you can see how it is done if needed.

Read our guides on how to handle button actions and events.

Next steps

Have questions or running into issues? Check out our support forum where you can find answers to common questions or ask your own. Our team and community are here to help!

Your flow is ready to be displayed in the app. Test your purchases in Google Play Store to make sure you can complete a test purchase from the flow.

Now, you need to check the users’ access level to ensure you display a flow or give access to paid features to right users.

Full example

Here is how all those steps can be integrated in your app together.