SAP

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Create Your Own Flow

Learn how to create your own flow with the framework provided by Jetpack Compose Flows component of SAP BTP SDK for Android.

Overview

You will learn

  • ✔How to create your own flow
  • ✔How to add flow steps to your own flow Besides the pre-defined flows described in the previous tutorials, the flows component also provides a framework for the client code to create its own flow. Typically, a flow consists of several flow steps, and also it might also include other flows as sub-flows. The Flows framework provides flexible ways for the client code to create a customized flow:
  • ✔The client code can create its own flow steps and then create a flow with the combination of the steps.
  • ✔The client code can create a flow with some single flow steps or combine sub-flows to create a customized flow.
  • ✔The client code can define the navigation logic for a customized flow.
Haoyue Feng H Haoyue Feng August 21, 2026
Created on May 15, 2024
Contributors

More from Haoyue Feng

See all 12 tutorials by Haoyue Feng →

Prerequisites

Steps

Details

You will learn

  • How to create your own flow
  • How to add flow steps to your own flow

Besides the pre-defined flows described in the previous tutorials, the flows component also provides a framework for the client code to create its own flow. Typically, a flow consists of several flow steps, and also it might also include other flows as sub-flows. The Flows framework provides flexible ways for the client code to create a customized flow:

  • The client code can create its own flow steps and then create a flow with the combination of the steps.
  • The client code can create a flow with some single flow steps or combine sub-flows to create a customized flow.
  • The client code can define the navigation logic for a customized flow.

Step 1 Write your own flow
—

Extend your flow class to the com.sap.cloud.mobile.flows.compose.flows.BaseFlow class, and implement the initialize function to add flow steps.

  1. Create a flow class named TestFlow:

    Kotlin
    class TestFlow(context: Context) : BaseFlow(context, "TestFlow") {
    
    }
  2. Implement the initialize function to create and add a customized flow step to your own flow:

    Kotlin
    override fun initialize() {
        val step1 = SingleStep(context, "step_1") {
            EulaScreen(
                eulaContentLocale = localeState.value,
                eulaScreenSettings = EulaScreenSettings(
                    eulaUrl = "file:///android_res/raw/custom_eula.html",
                    agreeButtonCaption = android.R.string.ok,
                    disagreeButtonCaption = android.R.string.cancel
                ),
                agreeViewClickListener = {
                    flowDone("step_1")
                },
                disagreeViewClickListener = {
                    terminateFlowWithMessage("Custom flow cancelled.")
                },
                webViewClient = object : WebViewClient() {
                    override fun shouldOverrideUrlLoading(
                        view: WebView?,
                        request: WebResourceRequest?
                    ): Boolean =
                        request?.url?.let { url ->
                            SDKCustomTabsLauncher.launchCustomTabs(context, url.toString())
                            true
                        } ?: false
                }
            )
        }
    
        addSingleStep(step1)
    }
Step 2 Add flow steps to your flow
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 2
1. Write your own flow 2. Add flow steps to your flow