Android project requirements
System requirements:- minSdk = 26 (Android 8.0)
- compileSdk = 34
- Android Gradle Plugin 8.1.4
- Kotlin 1.9.24
Installing the library
- Add the maven repository in your project’s
settings.gradle.ktsfile:
- Add the library as a dependency in your
app/build.gradle.ktsfile:
Library dependencies
Impactful dependencies:- Koin 3.2.2, including the implementation for Koin Context Isolation
- Compose BOM 2024.06.00 + Compose Compiler 1.5.14
- Accompanist 0.32.0
- Kotlin Coroutines 1.8.0
- OkHttp BOM 4.11.0
- Retrofit 2.9.0
- Coil Image Library 2.5.0
- Gson 2.11.0
Public API
The SDK library is managed through theFlowxSdkApi singleton instance, which exposes the following methods:
Configuring the library
To configure the SDK, call theinit method in your project’s application class onCreate() method:
Parameters
• Providing the
access token is explained in the authentication section.• The
custom components implementation is explained in its own section.• The implementation for providing a
custom view for the header of the Stepper component is detailed in its own section.• Collecting analytics events from the SDK is explained in its own section.
• Handling the start of a new process while in a running process is explained in its own section.
Sample
SdkConfig data for the config parameter above are:
Custom validators
Thecustom validators map is a collection of lambda functions, referenced by name (i.e. the value of the key in this map), each returning a Boolean based on the String which needs to be validated.
For a custom validator to be evaluated for a form field, its name must be specified in the form field process definition.
Using the library
Authentication
To be able to use the SDK, authentication is required. Therefore, before calling any other method on the singleton instance, make sure that the access token provider is set by calling:ai.flowx.android.sdk.FlowxSdkApi.Companion.AccessTokenProvider type, which is actually a functional interface defined like this:
Theming
To be able to use styled components while rendering a process, the theming mechanism must be invoked by calling thesuspend-ing setupTheme(...) method over the singleton instance of the SDK:
Parameters
If the
If the
themeUuid parameter value is empty (""), no theme will be fetched, and the mechanism will rely only on the fallback file, if set.If the
fallbackThemeJsonFileAssetsPath parameter value is null, there will be no fallback mechanism set in place, meaning if fetching the theme fails, the redered process will have no style applied over it’s displayed components.The SDK caches the fetched themes, so if a theme fetch fails, a cached version will be used, if available. Otherwise, it will use the file given as fallback.
Sample
Changing current locale settings
The currentlocale and language can be also changed after the initial setup, by calling the changeLocaleSettings function:
Parameters
Sample
For locale, use the format BCP 47. BCP 47 is the standard for representing language and region codes, here is a link to the BCP 47 specification.
An example of BCP 47 is
en-us (language code - en and region code - us).Start a FlowX process
After performing all the above steps and all the prerequisites are fulfilled, a new instance of a FlowX process can be started, by using thestartProcess function:
Parameters
Sample
Resume a FlowX process
To resume an existing instance of a FlowX process, after fulfilling all the prerequisites, use thecontinueProcess function:
Parameters
Sample
Custom components
The container application should decide which custom component view to provide using thecomponentIdentifier configured in the UI designer.
A custom component receives data to populate the view and actions available to execute, as described below.It can also be validated and provide data back into the process when executing an action. To handle custom components, an implementation of the
CustomComponentsProvider interface should be passed as a parameter when initializing the SDK:
Sample
CustomComposableComponent
The implementation for providing a custom component is based on creating and binding a user defined @Composable function, through theCustomComposable interface:
CustomComposable object is an interface defined like this:
Sample
Among multiple existing custom components, there may be one that:- allows the input of a value representing an
age - the value should be validated (e.g. to be at least 35 years old)
- the value will be passed back into the process
Execute action
The custom components which the container app provides may contain FlowX actions available for execution.These actions are received through the
actions parameter of the populateUi(actions: Map<String, CustomComponentAction>) method.In order to run an action (i.e. on a click of a button in the custom component) you need to call the
executeAction method:
Parameters
Get a substitution tag value by key
key.
It returns:
- the key’s counterpart, if the
keyis valid and found - the empty string, if the
keyis valid, but not found - the unaltered string, if the key has the wrong format (i.e. not starting with
@@)
Get a media item url by key
key.
It returns the URL string of the media resource, or null, if not found.
Custom header view for the STEPPER component
The container application can opt for providing a custom view in order to be used, for all the Stepper components, as a replacement for the built-in header.The custom view receives
data to populate its UI, as described below.
To provide a custom header for the Stepper, an implementation of the CustomStepperHeaderProvider interface should be passed as a parameter when initializing the SDK:
Sample
CustomComposableStepperHeader
To provide the custom header view as a @Composable function, you have to implement theCustomComposableStepperHeader interface:
ComposableStepperHeader object is an interface defined like this:
data parameter received as function argument is an interface defined like this:Sample
Collecting analytics events
To be able to collect analytics events from the SDK, an implementation for theAnalyticsCollector functional interface may be provided when initializing the SDK:
Event looks like this:
Sample
The implementation can be passed as a lambda, like:The value property represents the identifier set in the process definition.For action type events there are some additional properties provided:
- component - The type of component triggering the action
- label - The label of the component, if available. (E.g. title of a button or label of a form element)
- screen - The identifier of the screen containing the component, if set
Handling “Start of a new process”
When an action of typeSTART_PROJECT is executed, the onNewProcessStarted lambda provided in the FlowxSdkApi.getInstance().init(...) function is invoked.
This callback provides the UUID of the newly started process, which can be used to resume the process by calling the FlowxSdkApi.getInstance().continueProcess(...) method.
It is the responsibility of the container application’s developer to implement the necessary logic for displaying the appropriate UI for the newly started process.
Sample
One way to handle this is to send a broadcast message to notify the Activity currently displaying the running process. The Activity should handle the broadcast to reload and display the newly started process identified byprocessInstanceUuid (received in the broadcast intent).
Known issues
- shadows are rendered only on Android >= 28 having hardware acceleration enabled
- there is no support yet for subprocesses started using the Call Activity node when configuring a TabBar Navigation Area

