Skip to main content

Android SDK - Current (24.1.3)


The Atomic Android SDK is distributed as an AAR, allowing you to integrate an Atomic stream container or single card view into your Android app and present action cards to your customers.

The current stable release is 24.1.3.

Device and Version Support

Android 5/ Android 21 and above are supported. It is recommended to use the latest compileSdkVersion available.

Boilerplate app

You can use our Android boilerplate app to help you get started with the Atomic SDK for Android. You can download it from its GitHub repository. If you're working on a jetpack compose project, you can download the Jetpack Compose boilerplate here. Alternatively, you can follow this guide.


The SDK can be installed as a Gradle dependency or by manually downloading the AAR file.


The SDK is hosted on our public Maven repository. You'll need to add the following repository to your root build.gradle or settings.gradle file depending on how your project is setup:

    repositories {
maven {
url ""

Then, add the following to your app’s build.gradle

dependencies {
implementation 'io.atomic.actioncards:aacsdk:1.0.0'

Manual Installation

If you prefer to manually download and integrate the Atomic SDK into your app, you can download the AAR and POM files from the Packages section of the Android SDK releases repository.

If documentation doesn't appear in Android Studio

The Atomic SDK includes documentation for all public-facing methods, using the sources.jar file. Follow these steps if this documentation doesn't appear in Android Studio:

  1. Download the sources package (ending with sources.jar) from the Packages section of the Android SDK releases repository.
  2. Open a class in your app that uses a method from the Atomic SDK, and press F1 on that method in the SDK.
  3. Once the decompiled source code is shown, click on "Choose Source" from the top right.
  4. Use the system dialog to select the file downloaded in step 1.
  5. Close the decompiled source view. Press F1 again on the SDK method to view the source documentation.


Initialize the SDK

Before you can use the Atomic SDK, you must initialize it and provide the required configuration details.

Firstly, in your application's onCreate method, call the SDK init method, passing your application context:


Next, set your SDK API host, environment ID and API key. You can find these details in the Atomic Workbench.

Environment ID and API key

  • Open the Atomic Workbench, and navigate to the Configuration area.
  • Under the 'SDK' header, your API host is in the 'API Host' section, your API key is in the 'API Keys' section, and your environment ID is at the top of the page under 'Environment ID'.
Use the correct API host

The SDK API host is different to the API base URL endpoint, which is also available under Configuration. The SDK API host ends with


Login convenience method

Each individual setting can be applied singularly as above. Since SDK 1.3.4 you can also use a convenience method called login which allows populating the four main settings in one call. The parameters are as follows:

AACSDK.login(apiHost: String,
apiKey: String,
environmentId: String,
sessionDelegate: ((String?) -> Unit) -> Unit)

An example of calling login:

AACSDK.login("<apiHost>", "<apiKey>", "<environmentId>", requestToken)

Authenticating requests using a JWT

Atomic SDK uses a JSON Web Token (JWT) to perform authentications.

The SDK Authentication guide provides step-by-step instructions on how to generate a JWT and add a public key to the Workbench.

Within your host app, you will need to call the setSessionDelegate method to provide the requestToken object.


JWT expiry interval

The Atomic SDK allows you to configure the time interval to determine whether the JSON Web Token has expired. If the interval between the current time and the token's exp field is smaller than that interval, the token is considered to be expired. If this method is not set, the default value is 60 seconds. The interval must not be smaller than zero.

In the code sample below the interval is set to 5 minutes (300 seconds).


JWT retry interval

(Requires Atomic SDK 1.1.5+)

The Atomic SDK allows you to configure the timeout interval (in seconds) between retries to get a JSON Web Token from the session delegate if it returns a null token. The SDK will not request a new token for this amount of seconds from your supplied session delegate. The default value is 0, which means it will immediately retry your session delegate for a new token.


WebSockets and HTTP API Protocols

Atomic SDK uses WebSockets as a default communication protocol to fetch and send data to Atomic Platform. However, if the WebSockets connection is interrupted and cannot be re-established after three attempts, Atomic SDK fallbacks to HTTP.

Besides the default behavior, communication between the Atomic SDK and Atomic Platform can be established by using HTTP. To switch protocols use setApiProtocol:


Displaying containers

The Atomic Android SDK supports the following display modes:

  • Embedded - The stream container is being embedded inside of another view, and does not require a way to dismiss it. Both vertical and horizontal stream containers are embedded.
  • Single Card View — The first card from a stream container is displayed without any surrounding UI.

This section applies to all types of container: vertical, horizontal and single card view.

You need to embed containers inside an Activity that has fragment support, or inside a Fragment.

You'll need to pass:

  • Your stream container ID as a string;

You can then start the container by passing:

  • The ID of the view to embed the stream container in;
  • The fragment manager to support embedding of the stream container. If embedded in an Activity use getFragmentManager(); if embedding in a Fragment use getChildFragmentManager().
Saving states

You must retain stream container instances so that they are restored properly during configuration changes. More information on how to achieve this is available in the Android developer documentation. ViewModels are used in the examples below; however, any other state-saving technique that does not involve serialization, such as dependency injection, may also be used.

Special care must also be taken to ensure the SDK works after system-initated process death, follow the advice for managing system-iniated process death with the SDK here.

Stream container ID

First, you’ll need to locate your stream container ID.

Navigate to the Workbench, select Configuration > SDK > Stream containers and find the ID next to the stream container you are integrating.

// Example in a fragment
public class MyFragment extends Fragment {

private MyViewModel myViewModel;

public void onStart() {

if (myViewModel.streamContainer == null) {
myViewModel.streamContainer =

myViewModel.streamContainer.start(, this.getChildFragmentManager());

Note that AACStreamContainer.create is a factory method responsible for setting up an AACStreamContainer. The method start creates a new fragment or reuses an existing one and adds the stream container to the view matching the provided viewId parameter. This implies that AACStreamContainer.create should be called once for each stream container used in the app and start can be called multiple times, such as during configuration changes.

You should also call destroy on your stream container instance at the appropriate time. This method is responsible for destroying and removing any stream container fragments from the fragment manager passed to start. See the Disposing of a stream container section for more information.

Configuring multiple containers with a permanent container in the home screen

We recommend using FragmentManager.replace instead of add in the following scenario:

  • your app design has a stream container (either single card or multiple stream) as part of an always active home screen and
  • the app opens a fragment to show an additional container

This is due to Android lifecycle events (onPause/onResume) not triggering on the home fragment, as it is still active when there is another fragment above it on the stack. Closing that fragment does not trigger the lifecycle events and may cause unexpected results from the SDK.


// example of calling replace rather than add
binding.showCardsButton.setOnClickListener {
val cardFragment = CardFragment()
.replace(, cardFragment, "CARD_FRAGMENT")

If you are using a NavDrawer or Tabs then this is not an issue as the views are resumed or recreated.

Jetpack compose

Since the SDK uses a fragment to display the stream container, we cannot directly call it from compose. There are a few ways we can mix both worlds where you can have Jetpack Compose, but still able to launch the stream container along side it. In this sample, ComposeView is used to achieve that. You can checkout the boilerplate branch here.

Below is a class called ComposeFrameLayout which is a regular FrameLayout. This FrameLayout contains a ComposeView that returns Compose content.

class ComposeFrameLayout @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr) {

init {
ComposeView(context).apply {

setContent {
val toast = Toast.makeText(
"You have just interacted with a composable",

Column {
Row() {
MaterialTheme {
title = "Composable inside a FrameLayout",
description = "This is a sample code where you " +
"can create a composable which act as a normal view." +
"You can add this to your XML layout like a regular FrameLayout",
onClick = { },
buttonLabel = "Click me"

The XML layout below contains 3 container layouts. A regular FrameLayout, a ComposeView, and the ComposeFrameLayout created above. The FrameLayout with id stream_container is the container on which we want to display the stream container.


android:id ="@+id/compose_frameLayout"


The code below shows that the SDK uses the stream_container to load its fragment and at the same time write Jetpack Compose components by getting a reference from the composeView element from the XML. You can use this inside an Activity or a Fragment.

override fun onCreate(savedInstanceState: Bundle?) {


// Reference the viewModel
viewModel = ViewModelProvider(this)[]

// Start the stream container
viewModel.streamContainer?.start(, supportFragmentManager)

//Reference the composeView element from xml layout
val composeView = findViewById<ComposeView>(
//This is where you set your jetpack compose compose contents
composeView.apply {
//Dispose of the Composition when the view's LifecycleOwner is destroyed

setContent {
// Do all your compose stuffs here

Configuration options

Style and presentation

The stream container can be configured with different display modes, styling and behavior via the following properties:

  • presentationStyle: indicates how the stream container is being displayed. Either:
    • With no button in its top left (PresentationMode.WITHOUT_ACTION_BUTTON);
    • With an action button that triggers a custom action you handle (PresentationMode.WITH_ACTION_BUTTON).
  • toastMessagesEnabled: indicates whether toast messages are shown in the stream container. Defaults to true. From version 23.3.0 toast messages will also appear when using the single card view. Prior to this, the setting will have no effect on the single card view.
  • cardListHeaderEnabled: indicates whether the card list header should be shown in the stream container. Defaults to true and has no effect in single card view, as the card list header is always hidden.
  • launchBackgroundColor: The background color to use for the launch screen, seen on first load.
  • launchIconColor: The color of the icon displayed on the launch screen, seen on first load.
  • launchButtonColor: The color of the buttons that allow the user to retry the first load, if the request fails.
  • launchTextColor: The text color to use for the view displayed when the SDK is first presented.
  • statusBarBackgroundColor: The background color to use for the status bar on secondary screens, such as the snooze selection screen.
  • runtimeVariableAnalyticsEnabled: Whether the runtime-vars-updated analytics event should be sent when runtime variables are resolved. Defaults to true. If your runtime variables implementation includes sensitive data, you can set this flag to false to prevent such analytics events from being sent.
  • submitButtonWithPayloadActionHandler: Triggered when a submit button with an associated custom action payload, as defined in the Workbench, causes a card to be successfully submitted.
  • linkButtonWithPayloadActionHandler: Triggered when the user taps on a link button with an associated custom action payload, as defined in the Workbench.
  • cardListFooterMessage: An optional footer message to be displayed below the last card in the card list, if at least one is present, or null if no message should show. Does not apply in single card view.
  • interfaceStyle: The interface style (light, dark or automatic) to apply to the stream container.
  • verticalScrollingEnabled: An optional setting to control whether the single card view will automatically become scrollable when displaying a card longer than the length of its container. Defaults to true (Only available on AACSingleCardView).


  • cardListRefreshInterval: How frequently the card list should be refreshed. Defaults to 15 seconds, and must be at least 1 second. If set to 0 then polling is disabled.
Battery life

Setting the card refresh interval to a value less than 15 seconds may negatively impact device battery life and is not recommended.

  • actionDelegate: An optional delegate that handles actions triggered inside of the stream container, such as the tap of the custom action button in the top right of the stream container.
  • cardDidRequestRunTimeVariablesHandler: If your cards supply runtime variables you can provide this handler to resolve them.
  • runtimeVariableResolutionTimeout: Controls the timeout for the handler that supplies runtime variable values. If the timeout is reached, runtime variables will fall back to their default values.
  • cardVotingOptions: The voting options displayed for all cards in the stream container. By default, no voting options are enabled.

Custom strings

You can also customize the following strings on a stream container instance:

  • cardListTitle: The title to display at the top of the card list. If not specified, defaults to "Cards".
  • allCardsCompleted: The message displayed when the user has received at least one card before, and there are no cards to show - defaults to "All caught up".
  • awaitingFirstCard: The message displayed over the card list, when the user has never received a card before - defaults to "Cards will appear here when there’s something to action."
  • cardSnoozeTitle: The title for the feature allowing a user to snooze a card - defaults to "Remind me".
  • votingUsefulTitle: The title to display for the action a user taps when they flag a card as useful - defaults to "This is useful".
  • votingNotUsefulTitle: The title to display for the action a user taps when they flag a card as not useful - defaults to "This isn't useful".
  • votingFeedbackTitle: The title to display at the top of the screen allowing a user to provide feedback on why they didn't find a card useful - defaults to "Send feedback".
  • toastCardDismissMessage: Customized toast message for when the user dismisses a card - defaults to "Card dismissed"
  • toastCardCompletedMessage: Customized toast message for when the user completes a card - defaults to "Card completed"
  • toastCardSnoozeMessage: Customized toast messages for when the user snoozes a card - defaults to "Snoozed until X" where X is the time the user dismissed the card until.
  • toastCardFeedbackMessage: Customized toast message for when the user sends feedback (votes) for a card - defaults to "Feedback received"

Displaying a vertical container

To display a vertical container, you do not need to supply any additional parameters.

Creating a vertical stream container

The displaying containers section lists all the building blocks that are needed to create a container. The code below shows an example of how it all fits together. It shows how to set the session delegate using a request token, initialise a container with the container id 1234, assign the string Things to do as title on top of the container and assign the color black to the launch icon.

// Set Session Delegate
private Unit requestToken(Function1<? super String, Unit> onTokenReceived) {
try {
} catch (Exception e){
Log.debug("Error getting request Token ${e.message}");
return null;

final AACStreamContainer streamContainer = AACStreamContainer.create("1234");

// configure and start the container
streamContainer.setCardListTitle("Things to do");
streamContainer.start(, this.getChildFragmentManager());

Displaying a custom header

(Requires Atomic SDK 1.1.0+)

You can provide a custom layout xml file as a header that scrolls up along with the cards. The custom header is placed below the built-in header if the built-in one is enabled. It is provided by your app via streamContainer.customHeader = <>

Only for vertical stream containers.

It has no effect in the single card view.

The layout can be any valid XML based view layout. As no binding is done via the Atomic SDK, your view must have fixed assets and values set in the layout file. The view can reference any @color, @string or @drawable that is bundled with your app. For example:


<?xml version="1.0" encoding="utf-8"?>
android:text="THIS IS A TEST HEADER" />
android:text="Maybe a subtitle" />



android:text="Or anything really"/>
app:layout_constraintTop_toTopOf="parent" />

This would be called from your code when you initialise your AACStreamContainer.

// add a custom header here to the container, or null for none

Displaying a horizontal stream container

Displaying a horizontal stream container, where cards are shown from left to right, is not yet available in the Android SDK.

Displaying a single card

You can add a single card view to your app using the AACSingleCardView.create method. A single card view displays the first card in a given stream container, without any surrounding UI. This allows the card to fit in with the rest of your app UI.

In single card view, pull to refresh is disabled.

You configure a single card view in the same way as a vertical stream container, by passing:

  • Your stream container ID as a string;

You can then start the single card view by passing:

  • The ID of the view to embed the single card view in;
  • The fragment manager to support embedding of the single card view. If embedded in an Activity use getFragmentManager(); if embedding in a Fragment use getChildFragmentManager().
Saving states

You must retain stream container instances so that they are restored properly during configuration changes. More information on how to achieve this is available in the Android developer documentation.

Configuration options for the single card view

Single card view also supports an additional argument:

  • An optional callback - onChangeCardSize - which allows you to be notified when the single card view changes size.
// Example in a fragment
public class MyFragment extends Fragment {
public void onStart() {
final AACSingleCardView singleCard = AACSingleCardView.create("1234");
singleCard.start(, this.getChildFragmentManager());

Disposing of a stream container

To ensure that your stream container is disposed of correctly, you must call the destroy method on your stream container or single card view instance, passing the fragment manager you supplied to the start call. This will ensure that the fragment housing the stream container is removed. It is recommended to do this when the hosting Activity or Fragment is destroyed.

public class MyFragment extends Fragment {
AACStreamContainer streamContainer;

public void onDestroy() {

Customizing the first time loading experience

When a stream container with a given ID is launched for the first time on a user's device, the SDK loads the theme and caches it for future use. On subsequent launches of the same stream container, the cached theme is used and the theme is updated in the background, for the next launch. Note that this first time loading screen is not presented in single card view - if a single card view fails to load, it collapses to a height of 0.

The SDK supports some basic properties to style the first time load screen, which displays a loading spinner in the center of the container. If the theme fails to load for the first time, an error message is displayed with a 'Try again' button. One of two error messages are possible - 'Couldn't load data' or 'No internet connection'.

First time loading screen colors are customized using the following properties on AACStreamContainer:

  • launchBackgroundColor: the background of the first time loading screen. Defaults to white.
  • launchTextColor: the color to use for the error message shown when the theme fails to load. Defaults to black at 50% opacity.
  • launchLoadingColor: the color to use for the loading spinner on the first time loading screen. Defaults to black.
  • launchButtonColor: the color to use for the 'Try again' button, shown when the theme fails to load. Defaults to black.

You can also customize the text for the first load screen error messages and the 'Try again' button, using the following properties.

Note: These customized error messages also apply to the card list screen.

  • noInternetMessage: the error message shown when the user does not have an internet connection.
  • apiErrorMessage: the error message shown when the theme or card list cannot be loaded due to an API error.
  • tryAgainButtonTitle: the title of the button allowing the user to retry the failed request for the card list or theme.

API-driven card containers

(introduced in 23.4.0)

In version 23.4.0, we've introduced a new feature for observing stream containers with pure SDK API, even when that container's UI is not loaded into memory.

When you opt to observe a stream container, it is updated by default immediately after any changes in the published cards. Should the WebSocket be unavailable, the cards are updated at regular intervals, which you can specify. Upon any change in cards, the callback block is executed with the updated card list or null if the cards couldn't be fetched. Note that the specified time interval for updates cannot be less than 1 second.

The following code snippet shows the simplest use case scenario:

AACStreamContainer container = AACStreamContainer.create("containerId");

String token = AACSDK.observeStreamContainer(container, (update) -> {
Log.d("[Observer]", "Container updated");
return null;


Card instance class clusters

In the callback, the cards parameter is an list of Card objects. Each Card contains a variety of other class types that represent the card elements defined in Workbench. Detailed documentation for the classes involved in constructing a Card object is not included in this guide. However, you can refer to the examples provided below, which demonstrate several typical use cases.

Configuration options

Just like when using the UI stream containers, you can configure the AACStreamContainer object with optional configuration options. Not all options will apply to the API-driven stream container as some are specific to the UI. In order to configure these options, set the following properties on the AACStreamContainer instance before you call the startUpdates() method.

  • cardListRefreshInterval: defines how frequently the system checks for updates when the WebSocket service is unavailable. The default interval is 15 seconds, but it must be at least 1 second. If a value less than 1 second is specified, it defaults to 1 second.
  • cardDidRequestRunTimeVariablesHandler: a delegate for resolving runtime variables for the cards. Defaults to null. See Runtime variables for more details of runtime variables.
  • runtimeVariableResolutionTimeout: the maximum time allocated for resolving variables in the delegate. If the tasks within the delegate method exceed this timeout, or if the completionHandler is not called within this timeframe, default values will be used for all runtime variables. The default timeout is 5 seconds and it cannot be negative.
  • runtimeVariableAnalyticsEnabled: whether the runtime-vars-updated analytics event, which includes the resolved values of each runtime variable, should be sent upon resolution. The default setting is NO. If you set this flag to YES, ensure that the resolved values of your runtime variables do not contain sensitive information that shouldn't appear in analytics. See SDK analytics for more details on runtime variable analytics.

Stopping the observation

You can stop the observation using the token returned from the observation call mentioned above, please note this will not stop the SDK from continuing to receive updates for the stream container through WebSockets and polling. To stop these call the stopUpdates() method.

// Stops the observation callback.

// Closes WebSocket connection and stops polling


Accessing card metadata

Card metadata encompasses data that, while not part of the card's content, are still critical pieces of information. Key metadata elements include:

  • Card instance ID: This is the unique identifier assigned to a card upon its publication.
  • Card priority: Defined in the Workbench, this determines the card's position within the feed. A priority of 1 indicates the highest priority, placing the card at the top of the feed.
  • Action flags: Also defined in the Workbench, these flags dictate the visibility of options such as dismissing, snoozing, and voting menus for the card.

The code snippet below shows how to access these metadata elements for a card instance.

String token = AACSDK.observeStreamContainer(container, (update) -> {
if (update != null && update.get(0) != null) {
Card card = update.get(0);
Log.d("[Card]", "The card instance ID is: " + card.getInstance().getId());
Log.d("[Card]", "The card priority is: " + card.getMetadata().getPriority());
Log.d("[Card]", "The card has a dismiss overflow menu: " + card.getActions().getDismiss().getOverflow());
return null;

Traversing card elements

Elements refer to the contents that are defined in the Workbench on the Content page of a card. All elements that are at the same hierarchical level within a card are encapsulated in an LayoutNode object. Elements at the top level are accessible through the defaultLayout property of the CardInstance. The nodes property within defaultLayout contains them.

The code snippet below shows how to traverse through all the elements in a card and extract the text representing the card's category.

String token = AACSDK.observeStreamContainer(container, (update) -> {
if (update != null && update.get(0) != null) {
Card card = update.get(0);
card.getDefaultView().getNodes().forEach((layoutNode -> {
String type = layoutNode.getType();
if (type.equals("category")) {
Object rawText = layoutNode.getAttributes().get("text");
String textWithVariablesReplaced = card.stringWithResolvedVariables(rawText);
Log.d("[Node]", "Category nodes text is " + textWithVariablesReplaced);
return null;

The LayoutNode class can represent properties for the various elements you can create in Workbench. Detailed documentation for all these properties is not provided, but they correspond to the raw card JSON viewable in the workbench.

Accessing subviews

Subviews are layouts that differ from the defaultLayout and each has a unique subview ID. See Link to subview on how to get the subview ID.

The following code snippet shows how to retrieve a subview layout using a specific subview ID.

  String token = AACSDK.observeStreamContainer(container, (update) -> {
if (update != null && update.get(0) != null) {
Card card = update.get(0);
CardSubview subview = card.getSubviews().get("subviewId");
if (subview != null) {
String title = card.stringWithResolvedVariables(subview.getTitle());
Log.d("[Subview]", "Title is " + title);
return null;

API-driven card actions

(introduced in 23.4.0)

In version 23.4.0, we've introduced a new feature that execute card actions through pure SDK API. The currently supported actions are: dismiss, submit, and snooze. To execute these card actions, follow these two steps:

  1. Create a card action object: Use the corresponding initialization methods of the AACCardAction class. You'll need a AACStreamContainer instance and a card instance ID or Card object for this. The card instance ID can be obtained from the API-driven stream container. See API-driven card containers for more details.

  2. Execute the action: Call the method AACSDK.onCardAction to perform the card action.

  3. Check the result of the action in the result callback.

Dismissing a card

The following code snippet shows how to dismiss a card.

AACSDK.onCardAction(container, new AACCardAction.Dismiss(Card.createWithId("cardInstanceId")), (aacCardActionResult) -> {
if (aacCardActionResult instanceof AACCardActionResult.Success) {
Log.d("[CardAction]", "Dismiss successful");
} else if (aacCardActionResult instanceof AACCardActionResult.DataError) {
Log.d("[CardAction]", "Dismiss data error");
} else {
Log.d("[CardAction]", "Dismiss network error");
return null;

Submitting a Card

You have the option to submit certain values along with a card. These values are optional and should be encapsulated in an HashMap<String, Any> object, using String keys and values that are either strings, numbers, or booleans.

Input Components

While editing cards in Workbench, you can add input components onto cards and apply various validation rules, such as Required, Minimum length, or Maximum length. The input elements can be used to submit user-input values, where the validation rules are applied when submitting cards through UIs of stream containers. However, for this non-UI version, support for input components is not available yet. There is currently no mechanism to store values in these input components through this API, and the specified validation rules won't be enforced when submitting cards.

The following code snippet shows how to submit a card with specific values.

AACStreamContainer container = AACStreamContainer.create("containerId");
HashMap<String, Object> map = new HashMap<>();
map.put("stringKey", "value");
map.put("numericKey", 22);
map.put("booleanKey", false);

AACSDK.onCardAction(container, new AACCardAction.Submit(Card.createWithId("cardInstanceId"), map), (aacCardActionResult) -> {
if (aacCardActionResult instanceof AACCardActionResult.Success) {
Log.d("[CardAction]", "Dismiss successful");
} else if (aacCardActionResult instanceof AACCardActionResult.DataError) {
Log.d("[CardAction]", "Dismiss data error");
} else {
Log.d("[CardAction]", "Dismiss network error");
return null;

Snoozing a Card

When snoozing a card, you must specify a non-negative interval in seconds. The following code snippet shows how to snooze a card for a duration of 1 minute (60 seconds).

AACSDK.onCardAction(container, new AACCardAction.Snooze(Card.createWithId("cardInstanceId"), 60), (aacCardActionResult) -> {
if (aacCardActionResult instanceof AACCardActionResult.Success) {
Log.d("[CardAction]", "Dismiss successful");
} else if (aacCardActionResult instanceof AACCardActionResult.DataError) {
Log.d("[CardAction]", "Dismiss data error");
} else {
Log.d("[CardAction]", "Dismiss network error");
return null;

Dark mode

Stream containers and single card views support dark mode. You configure an (optional) dark theme for your stream container in the Atomic Workbench.

The interface style determines which theme is rendered:

  • AACInterfaceStyle.AUTOMATIC: If the user's device is currently set to light mode, the stream container will use the light (default) theme. If the user's device is currently set to dark mode, the stream container will use the dark theme (or fallback to the light theme if no dark theme is configured). On Android versions that don't support night mode, this setting is equivalent to AACInterfaceStyle.LIGHT.
  • AACInterfaceStyle.LIGHT: The stream container will always render in light mode, regardless of the device setting.
  • AACInterfaceStyle.DARK: The stream container will always render in dark mode, regardless of the device setting.

To change the interface style, set the corresponding value for the interfaceStyle property on your AACStreamContainer or AACSingleCardView instance.

Filtering cards

(Requires Atomic SDK 1.3.5+)

Stream containers (vertical or horizontal), single card views and container card count observers can have one or more filters applied. These filters determine which cards are displayed, or how many cards are counted.

A stream container filter consists of two parts: a filter value and an operator.

Filter values

The filter value is used to filter cards in a stream container. The following list outlines all card attributes that can be used as a filter value.

Card attributeDescriptionValue type
PriorityCard priority defined in Workbench, Card -> DeliveryInt
Card template created dateThe date time when a card template is createdDate
Card template IDThe template ID of a card, see below for how to get itString
Card template nameThe template name of a cardString
Custom variableThe variables defined for a card in Workbench, Card -> VariablesMultiple

Use corresponding static methods of AACCardFilterValue to create a filter value.


Card priority

The following code snippet shows how to create a filter value that represents a card priority 3.

val filterValue = AACCardFilterValue.byPriority(3)
Custom variable

The following code snippet shows how to create a filter value that represents a boolean custom variable isSpecial.

val filterValue = AACCardFilterValue.byVariableName("isSpecial", false)

Note: It's important to specify the right value type when referencing custom variables for filter value. There are five types of variables in the Workbench, currently four are supported: String, Number, Date and Boolean.

How to get the card template ID

On the card editing page, click on the ID part of the overflow menu at the upper-right corner.

Card template ID

Filter operators

The operator is the operational logic applied to a filter value (some operators require 2 or more values).

The following table outlines available operators.

OperatorDescriptionSupported types
equalToEqual to the filter valueInt, Date, String, Boolean
notEqualToNot equal to the filter valueInt, Date, String, Boolean
greaterThanGreater than the filter valueInt, Date
greaterThanOrEqualToGreater than or equal to the filter valueInt, Date
lessThanLess than the filter valueInt, Date
lessThanOrEqualToLess than or equal to the filter valueInt, Date
containsIn one of the filter valuesInt, Date, String
notInNot in one of the filter valuesInt, Date, String
betweenIn the range of start and end, inclusiveInt, Date

After creating a filter value, use the corresponding static method on the AACCardListFilter class to combine it with an operator.


Card priority range

The following code snippet shows how to create a filter that filters card with priority between 2 and 6 inclusive.

val fv1 = AACCardFilterValue.byPriority(2)
val fv2 = AACCardFilterValue.byPriority(6)
val filter = AACCardListFilter.between(listOf(fv1, fv2))
Passing correct value type to an operator

Each operator supports different type of values. For example, operator lessThan only support Int and Date. So passing String values to that operator will raise an exception.

Applying filters to a stream container

There are three steps to filter cards in a stream container:

  1. Create one or more AACCardFilterValue objects.

  2. Combine filter values with filter operators to form a AACCardFilter.

  3. Apply filter(s).

    3.1. For stream containers, call streamContainer.applyFilter(listOf(filter1, filter2) to apply multiple filters, otherwise call streamContainer.applyFilter(myFilter). To delete all existing filters, pass an empty list [] to applyFilter.


Card priority 5 and above

The following code snippet shows how to only display cards with priority > 5 in a stream container.

val fv1 = AACCardFilterValue.byPriority(5)
val filter = AACCardListFilter.greaterThan(fv1)

// Acquire the stream container object and apply filter
Card template names

The following code snippet shows how to only display cards with the template names 'card 1', 'card 2', or 'card 3' in a stream container.

val fv1 = AACCardFilterValue.byCardTemplateName("card1")
val fv2 = AACCardFilterValue.byCardTemplateName("card2")
val fv3 = AACCardFilterValue.byCardTemplateName("card3")
val filter = AACCardListFilter.contains(listOf(fv1, fv2, fv3))

// Acquire the stream container object and apply filter
Combination of filter values

The following code snippet shows how to only display cards with priority != 6 and custom variable isSpecial == true in a stream container.

Note: isSpecial is a Boolean custom variable defined in Workbench.

val fv1 = AACCardFilterValue.byPriority(6)
val filter1 = AACCardListFilter.notEqualTo(fv1)

val fv2 = AACCardFilterValue.byVariableName("isSpecial", true)
val filter2 = AACCardListFilter.notEqualTo(fv2)


// Acquire the stream container object and apply filter
streamContainer.applyFilter(listOf(fv1, fv2))

Legacy filter

Stream containers and single card views can have an optional filter applied, which affects the cards displayed.

One filter is currently supported - filterCardsById. This filter requests that the stream container or single card view show only a card matching the specified card instance ID, if it exists. This method is called on an instance of AACStreamContainer or AACSingleCardView.

The card instance ID can be found in the push notification payload, allowing you to apply the filter in response to a push notification being tapped.

streamContainer.filterCardsById(this.getChildFragmentManager(), "cardId");

In the Atomic Workbench, you can create a submit or link button with a custom action payload.

  • When such a link button is tapped, the linkButtonWithPayloadActionHandler callback is invoked on your stream container.
  • When such a submit button is tapped, and after the card is successfully submitted, the submitButtonWithPayloadActionHandler callback is invoked on your stream container.

These callbacks are passed an action object, containing the payload that was defined in the Workbench for that button. You can use this payload to determine the action to take, within your app, when the submit or link button is tapped.

The action object also contains the card instance ID and stream container ID where the custom action was triggered.

streamContainer.setSubmitButtonWithPayloadActionHandler(action -> {
// Perform an action when the submit button successfully submits the card.
return Unit.INSTANCE;

streamContainer.setLinkButtonWithPayloadActionHandler(action -> {
// Perform an action when the link button with a custom payload is tapped.
return Unit.INSTANCE;

Customizing toast messages for card events

(Requires Atomic SDK 1.1.0+)

You can customize any of the toast messages used when dismissing, completing, snoozing and placing feedback on a card. This is configurable for each stream container and you simply supply a string for each custom message. If you do not supply a string the defaults will be used.

Options are:

  • toastCardDismissMessage: Customized toast message for when the user dismisses a card - defaults to "Card dismissed"
  • toastCardCompletedMessage: Customized toast message for when the user completes a card - defaults to "Card completed"
  • toastCardSnoozeMessage: Customized toast messages for when the user snoozes a card - defaults to "Snoozed until X" where X is the time the user dismissed the card until.
  • toastCardFeedbackMessage: Customized toast message for when the user sends feedback (votes) for a card - defaults to "Feedback received"
streamContainer.setToastCardDismissMessage("The card has been dismissed");
streamContainer.setToastCardCompletedMessage("The card has been completed");
streamContainer.setToastCardSnoozeMessage(null); // this will show the default. Assigning null is optional
streamContainer.setToastCardFeedbackMessage("Thanks for the feedback");

Card snoozing

The Atomic SDKs provide the ability to snooze a card from a stream container or single card view. Snooze functionality is exposed through the card’s action buttons, overflow menu and the quick actions menu (exposed by swiping a card to the left, on iOS and Android).

Tapping on the snooze option from either location brings up the snooze date and time selection screen. The user selects a date and time in the future until which the card will be snoozed. Snoozing a card will result in the card disappearing from the user’s card list or single card view, and reappearing again at the selected date and time. A user can snooze a card more than once.

When a card comes out of a snoozed state, if the card has an associated push notification, and the user has push notifications enabled, the user will see another notification, where the title is prefixed with Snoozed:.

You can customize the title of the snooze functionality, as displayed in a card’s overflow menu and in the title of the card snooze screen. The default title, if none is specified, is Remind me.

On an AACStreamContainer instance, call the appropriate setter to change the title of the card snooze feature:


Card voting

The Atomic SDKs support card voting, which allows you to gauge user sentiment towards the cards you send. When integrating the SDKs, you can choose to enable options for customers to indicate whether a card was useful to the user or not, accessible when they tap on the overflow button in the top right of a card.

If the user indicates that the card was useful, a corresponding analytics event is sent for that card (card-voted-up).

If they indicate that the card was not useful, they are presented with a secondary screen where they can choose to provide further feedback. The available reasons for why a card wasn’t useful are:

  • It’s not relevant;
  • I see this too often;
  • Something else.

If they select "Something else", a free-form input is presented, where the user can provide additional feedback. The free form input is limited to 280 characters. After tapping "Submit", an analytics event containing this feedback is sent (card-voted-down).

You can customize the titles that are displayed for these actions, as well as the title displayed on the secondary feedback screen. By default these are:

  • Thumbs up - "This is useful";
  • Thumbs down - "This isn’t useful";
  • Secondary screen title - "Send feedback".

Card voting is disabled by default. You can enable positive card voting ("This is useful"), negative card voting ("This isn’t useful"), or both:

streamContainer.setCardVotingOptions(EnumSet.of(VotingOption.Useful, VotingOption.NotUseful)); // Enable both voting options
streamContainer.setCardVotingOptions(EnumSet.of(VotingOption.Useful)); // Enable one voting option
streamContainer.setCardVotingOptions(EnumSet.of(VotingOption.None)); // Disable voting (default)

You can also customize the titles for the card voting options, and the title displayed at the top of the feedback screen, presented when a user indicates the card wasn’t useful:

streamContainer.setVotingFeedbackTitle("Provide feedback");
streamContainer.setVotingUsefulTitle("Thumbs up");
streamContainer.setVotingNotUsefulTitle("Thumbs down");

Refreshing a stream container manually

There is no method that allows you to manually refresh a container in the Android SDK (unlike iOS).
As soon as a new card is available, the container is refreshed.

Responding to card events

The SDK allows you to perform custom actions in response to events occurring on a card, such as when a user:

  • submits a card;
  • dismisses a card;
  • snoozes a card;
  • indicates a card is useful (when card voting is enabled);
  • indicates a card is not useful (when card voting is enabled).

To be notified when these happen, assign a card event handler to your stream container:

streamContainer.setCardEventHandler(event -> {
// Perform an action in response to the provided event
return Unit.INSTANCE;

Sending custom events

You can send custom events directly to the Atomic Platform for the logged in user, via the sendUserSettings function from AACSDK

A custom event can be used in the Workbench to create segments for card targeting. For more details of custom events, see Custom Events.

The event will be created for the user defined by the authentication token returned in the session delegate. As such, you cannot specifically target user IDs using this function.

HashMap properties = new HashMap<String, String>();
properties.put("firstName", "Fred");
properties.put("surname", "Flintstone");
AACCustomEvent event = new AACCustomEvent("myCustomEvent", properties);
AACSDK.sendCustomEvent(event, null); // assign a completion handler if required, but null in this example

Push notifications

The Android SDK supports push notifications via Firebase Cloud Messaging (FCM). You'll need to add your Service account private key (JSON) file to the Workbench and complete some app and SDK level configuration.

For a working example of integrating push notifications in a native Android app, see the notifications branch of our boilerplate app.

Configure Firebase Cloud Messaging (FCM)

To use push notifications in the SDK you'll need to have FCM set up for your application. If you haven't done that yet, follow the Firebase Cloud Messaging guide to set up an Android client.

Custom Channel ID

You can also configure Atomic push notifications to be sent with a custom channel ID, which places them in a specific channel within your app's notification settings. This feature is supported in Android 8 (API 26) and above, and can be configured using the notification platforms API. More information on this API is available in our SNS platform documentation. If you do not configure your notification platform with a custom channel ID, Atomic push notifications will be placed in a default Miscellaneous channel.

Configure your Notification Platform

Once you have FCM set up you'll need to create a new Notification Platform in the Workbench.

To add a Notification Platform, see: Notifications in the Configuration area.

Register the user against specific stream containers for push notifications

You need to indicate to the Atomic Platform which stream containers are eligible to receive push notifications in your app for the current device.

ArrayList<String> streamContainerIds = new ArrayList<>();


You will need to do this each time the logged in user changes.

To deregister the device for Atomic notifications for your app, such as when a user completely logs out of your app, call deregisterDeviceForNotifications on AACSDK:


This should be done before the call to logout().

Registration and deregistration callback

The following methods take an additional parameter - a callback that is invoked when the request completes, to indicate whether it succeeded or failed:

  • AACSDK.deregisterDeviceForNotifications

  • AACSDK.registerStreamContainersForNotifications

  • AACSDK.registerDeviceForNotifications

This allow you to retry the request to register the push token, or register a user for notifications in the given stream containers, in the event that the request fails.

For example, in the following code registerDeviceForNotifications calls the method retryRegisterForNotifications when registerDeviceForNotifications doesn't succeed:

(it) -> {
if (! it.isSuccess()){
return Unit.INSTANCE;

Note that the callback is an optional parameter, so if no callback is required, just use null, or in Kotlin omit it entirely:

AACSDK.registerStreamContainersForNotifications(streamContainerIds, null);

Register the device to receive notifications

Whenever your Firebase push token changes, you'll need to register it with Atomic so that notifications can be sent to the device.

One way to do this is by extending the FirebaseMessagingService and listening for token changes. This method may get called on app startup, before you have set up the SDK or received your JWT token from your authentication process. To ensure that the authenticated API call to Atomic can succeed, save the token in this method and call the registerDeviceForNotification methods later, after you have set up the SDK.

public class FirebaseMessagingService extends {

public void onNewToken(@NonNull String s) {

// Save the device token, you may then use this token to call AACSDK.registerDeviceForNotifications(token)
// After you have setup Atomic with your sessionDelegate

Alternatively, you can get the current token using the FirebaseMessaging.getInstance().token property, this will work at any time and avoids having to cache the token.

.addOnCompleteListener(new OnCompleteListener<String>() {
public void onComplete(@NonNull Task<String> task) {
if (!task.isSuccessful()) {
Log.w(TAG, "Fetching FCM registration token failed", task.getException());

// Get new FCM registration token
String token = task.getResult();

// Register the device token with Atomic

Detect push notifications originating from Atomic

Use the AACSDK.notificationFromPushPayload method to determine if a notification originated from Atomic and, if so, extract specific data from the notification.

Atomic push notification objects (AACPushNotification) contain:

  • the instance ID of the card the push notification relates to;
  • the ID of the stream container where the push notification was generated;
  • any custom data that you choose to supply as part of the event that generated the card.

The custom data that you supply can be used in your decision making, to determine which action to take in response to the notification.

If the provided push notification did not originate from Atomic, this method will return null.

When your app is running in the foreground

In your FirebaseMessagingService subclass, you can intercept and check for Atomic notifications in onMessageReceived, as in the example below.

public class FirebaseMessagingService
extends {

public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
Map data = remoteMessage.getData();
AACPushNotification pushNotification = AACSDK.notificationFromPushPayload(data);

if (pushNotification != null) {
// This is an Atomic push notification, do something here.
// You may choose to create a notification to display in the notification tray, or store some state for later use.

When your app is running in the background

By default, tapping on an Atomic push notification that is generated while your app is in the background will launch your app.

Within the activity that is launched, you can call AACSDK.notificationFromPushPayload, passing the intent. If the push notification that triggered app launch originated from Atomic, this method will return an AACPushNotification object; otherwise, it will return null.

public class MyActivity extends Activity {

protected void onCreate(@Nullable Bundle savedInstanceState) {

AACPushNotification pushNotification = AACSDK.notificationFromPushPayload(getIntent())

if (pushNotification != null) {
// This intent was started from an Atomic push notification.
// You may choose to navigate to a particular screen, or save some state for later use.

Retrieving card count without displaying a Stream Container

The Atomic SDK exposes a LiveData object where the count active cards can be obtained. Such object can be obtained by calling AACSDK.getLiveCardCountForStreamContainer.

final Observer<String> countObserver = new Observer<String>() {
public void onChanged(@Nullable final int newCount) {
// Update the UI, in this case, a TextView.
Log.d("MyApp", "Card count: $newCount");
AACSDK.getLiveCardCountForStreamContainer(aacStreamContainer).observe(this, countObserver);

To have getLiveCardCountForStreamContainer update its values, AACStreamContainer must be initialized to receive updates without UI binding.

val streamContainer = AACStreamContainer(streamContainerId);

Start updates schedules polling for new feed updates, and if WebSockets are opens a WebSocket connection and subscribes to the Atomic platform for live updates to the containers feed. It requires its Runtime Variable Handler and any other Stream Container Settings to be set on the container AACStreamContainer object before this method is called.

Because startUpdates is not controlled by a lifecycle-aware component such as a fragment or activity, it must be manually stopped to prevent leaking memory or using more of the users resources than neccesary. To stop the scheduled updates and un-subscribe from further upates call stopUpdates() in the onDestroy() method of your activity or fragment.

 public void onDestroy() {

Retrieving the count of active and unseen cards

What is an active card? What is an unseen card?

All cards are unseen the moment they are sent. A card becomes "seen" when it has been shown on the customer's screen (even if only briefly or partly). A quick scroll-through might not make the card "seen", this depends on the scrolling speed. The user metrics only count "active" cards, which means that snoozed and embargoed cards will not be included in the count.

The Atomic Android SDK exposes an object where user specific card count information can be found: user metrics. These metrics include:

  • The number of cards available to the user across all stream containers;
  • The number of cards that haven't been seen across all stream containers;
  • The number of cards available to the user in a specific stream container (equivalent to the card count functionality in the previous section);
  • The number of cards not yet seen by the user in a specific stream container.

These metrics enable you to display badges in your UI that indicate how many cards are available to the user but not yet viewed, or the total number of cards available to the user.

This method returns null if user metrics cannot be retrieved.

AACSDK.userMetrics(userMetrics -> {
if(userMetrics != null) {
Log.d("User metrics", "Total cards in all containers: " + userMetrics.getTotalCards());
Log.d("User metrics", "Unseen cards in all containers: " + userMetrics.getUnseenCards());

Log.d("User metrics", "Total cards in container: " + userMetrics.totalCardsForStreamContainer("containerId"));
Log.d("User metrics", "Unseen cards in container: " + userMetrics.unseenCardsForStreamContainer("containerId"));

return Unit.INSTANCE;

In order to retrieve the user metrics object, and receive information about the nature of the error if the request fails. You may use the userMetricsWithResultFunction.

AACSDK.userMetricsWithResult(result -> {
if (result instanceof AACSDKUserMetricsResult.Success) {
Log.d("User Metrics", ((AACSDKUserMetricsResult.Success) result).getUserMetrics().toString());
if (result instanceof AACSDKUserMetricsResult.DataError) {
Log.d("User Metrics", ((AACSDKUserMetricsResult.DataError) result).getError().toString());
return Unit.INSTANCE;

Runtime variables

Runtime variables are resolved in the SDK at runtime, rather than from an event payload when the card is assembled. Runtime variables are defined in the Atomic Workbench.

The SDK will ask the host app to resolve runtime variables when a list of cards is loaded (and at least one card has a runtime variable), or when new cards become available due to WebSockets pushing or HTTP polling (and at least one card has a runtime variable).

Only string values

Runtime variables can currently only be resolved to string values.

Runtime variables are resolved via the AACStreamContainer.cardDidRequestRunTimeVariablesHandler callback. If this callback is not provided then runtime variables will fall back to their default values, as defined in the Atomic Workbench.

This method, when called by the SDK, provides you with:

  • An array of objects representing the cards in the list. Each card object contains:
    • The event name that triggered the card’s creation;
    • The lifecycle identifier associated with the card;
    • A method that you call to resolve each variable on that card (resolveVariableWithNameAndValue(name, value)).
  • A callback (completionHandler), that must be called by the host app with resolved cards once all variables are resolved.

If a variable is not resolved, that variable will use its default value, as defined in the Atomic Workbench.

If you do not call the completionHandler before the runtimeVariableResolutionTimeout elapses (defined on AACStreamContainer), the default values for all runtime variables will be used. Calling the completion handler more than once has no effect.

(List<AACCardInstance> aacCardInstances,
Function1<? super List<AACCardInstance>, Unit> unitFunction1) -> {
for (AACCardInstance card : aacCardInstances) {
card.resolveVariableWithNameAndValue("numberOfItems", "12");


return Unit.INSTANCE;

Updating runtime variables manually

You can manually update runtime variables at any time by calling the updateVariables method on AACStreamContainer:


Accessibility and fonts

The Atomic SDKs support a variety of accessibility features on each platform. These features make it easier for vision-impaired customers to use Atomic's SDKs inside of your app.

These features also allow your app, with Atomic integrated, to continue to fulfil your wider accessibility requirements.

Dynamic font scaling

The Atomic Android SDKs supports dynamic font scaling. Typography styles opt-in to dynamic scaling to respond to the font size preference set by the user in their device settings. On Android, this feature is enabled in the Settings app, under "Font size".

To opt-in to dynamic font scaling:

  1. Open the Atomic Workbench.
  2. Navigate to the Theme Editor (Configuration > SDK > Container themes).
  3. Select a theme and then a typography style inside of that theme (e.g. Headline > Typography).
  4. Toggle the 'Dynamic sizing' switch on, and optionally supply a minimum and maximum font size.

Typography styles that do not have 'Dynamic scaling' enabled stay at a fixed size regardless of the user's text size (this is the default behavior for all typography styles).

Font sizing behavior

When the user changes their system-wide text size on Android, the SDK will automatically re-render any components containing typography styles that opt-in to dynamic scaling (typography styles that have the 'Dynamic scaling' option enabled in the stream container theme).

Example scaling scenario

A typography style is configured in the Workbench with the following properties:

  • Font size: 17px
  • Dynamic scaling: On
  • Dynamic scaling minimum size: 15px
  • Dynamic scaling maximum size: 30px

On Android, the following font sizes would be used for each scale factor (examples only; actual scale factors returned by the operating system may differ):

Scale factorResultant size
0.7515px (12.75px is below min)
230px (34px is above max)

Alternate text

As of Android SDK 0.16.0, alternate text is supported on all image and video components. This alternate text is supplied by you when authoring a card, and is used to describe the image or video itself. Alternate text forms part of a description that is passed to the system screen reader (when enabled).

The following description is used for each image or video format:

FormatText supplied to screen reader
BannerAlternate text
InlineAlternate text
TextLabel is used (also defined in the Workbench), as this component does not render an image thumbnail
ThumbnailAlternate text, label and description

Using embedded fonts in themes

(Requires Atomic SDK 1.0.0+)

To map a font in a stream container theme to one embedded in your app, use the registerEmbeddedFonts method on AACSDK, passing an array of AACEmbeddedFont objects, each containing the following:

  • A familyName that matches the font family name declared in the theme within the Atomic Workbench;
  • A weight - either AACFontWeight.Bold or AACFontWeight.None;
  • A style - either AACFontStyle.Italic or AACFontStyle.None;
  • A typeface, as a Typeface object, which provides a font loaded from your app's resources. This can be a font bundled with your application or one provided by the operating system.

If the familyName, weight and style of a font in the stream container theme matches an AACEmbeddedFont instance that you've registered with the SDK, the SDK will use the typeface when applying that font, and will not download the font from a remote URL.

In the example below, any use of a custom font named BrandFont in your theme, that is bold and italicized, would use the system monospace font instead:

Invalid font references

If the family name, weight and style do not match a custom font in the stream container theme exactly, the SDK will download the font at the remote URL specified in the theme instead.

AACSDK.registerEmbeddedFonts(Arrays.asList(new AACEmbeddedFont[]{
new AACEmbeddedFont("BrandFont", Typeface.MONOSPACE, AACFontWeight.Bold, AACFontStyle.Italic)

SDK Analytics

If you use runtime variables on a card, you can optionally choose to send the resolved values of any runtime variables back to the Atomic Platform as an analytics event. This per-card analytics event - runtime-vars-updated - contains the values of runtime variables rendered in the card and seen by the end user. Therefore, you should not enable this feature if your runtime variables contain sensitive data that you do not wish to store on the Atomic Platform.

To enable this feature, set the runtimeVariableAnalyticsEnabled flag on your stream container or single card view:


Network request security

The Atomic Android SDK provides functionality to further secure the SDK implementation in your own app.

Allow or deny network requests

You can choose to implement an SDK-wide network request handler, which determines whether requests originating from the Atomic SDK are allowed to proceed. This enables you to permit network requests only to domains or subdomains that you approve.

To enable this functionality, create a request handler implementing the AACNetworkRequestHandler interface, implement the dispositionForAtomicRequest(url) method and call setNetworkRequestHandler on AACSDK to assign it to the SDK. The request handler is called for every network request from the SDK.

Within the dispositionForAtomicRequest method, you can inspect the request URL and return one of the following dispositions:

  • AACNetworkRequestDisposition.Allow: The request is allowed to proceed.
  • AACNetworkRequestDisposition.Deny: The request is not allowed to proceed and will be cancelled.
  • AACNetworkRequestDisposition.AllowWithCertificatePins: The request can proceed if a hash of the subject public key info (SPKI) from part of the certificate chain matches one of the pin objects provided (see below for more information).

If you do not implement this request handler, all requests are permitted.

Allow requests with certificate pinning

When you return AACNetworkRequestDisposition.AllowWithCertificatePins in the AACNetworkRequestHandler above, you will be required to supply a list of AACCertificatePin objects. Each object contains a SHA-256 hash of the subject public key info (SPKI) from part of the domain's certificate chain, which is then base64 encoded.

Pin to all available Amazon certificates

When pinning requests for the Atomic API (<orgId>, we strongly recommend pinning to all available Amazon root certificates, which is the approach recommended by Amazon Web Services. SHA256 hashes for Amazon's root certificates are available on the Amazon Trust website.

You can convert these SHA256 hashes to a base64 representation, as required by the SDK, using the following Terminal command: openssl base64 -e <<< "<SHA256 hash>"

If the hashed, base64-encoded SPKI from part of the request's certificate chain matches any of the provided pin objects, the request is allowed to proceed. If it does not match any of the provided pins, the request is denied.

If you return this disposition for a non-HTTPS request, the request will be denied.

AACSDK.setNetworkRequestHandler(new AACNetworkRequestHandler() {
public AACNetworkRequestDisposition dispositionForAtomicRequest(@NotNull String url) {
Uri uri = Uri.parse(url);

if(uri.getHost() == null) {
return Deny.INSTANCE;

switch(uri.getHost()) {
case "":
ArrayList<AACCertificatePin> pins = new ArrayList();
pins.add(new AACCertificatePin("AAAAAA="));

return new AACNetworkRequestDisposition.AllowWithCertificatePins(pins);
case "":
return Allow.INSTANCE;
return Deny.INSTANCE;

Updating user data

(Requires Atomic Android SDK 1.2.4+)

The SDK allows you to update profile & preference data for the logged in user via the updateUser method of AACSDK.

Setting up profile fields

For simple setup, create an AACUserSettings object and set some profile fields, then call the method AACSDK.updateUser(userSettings, callback). The following optional profile fields can be supplied to update the data for the user:

  • external_id: An optional string that represents an external identifier for the user.
  • name: An optional string that represents the name of the user.
  • email: An optional string that represents the email address of the user.
  • phone: An optional string that represents the phone number of the user.
  • city: An optional string that represents the city of the user.
  • country: An optional string that represents the country of the user.
  • region: An optional string that represents the region of the user.

Any fields which have not been supplied will remain unmodified after the user update.

The following code snippet shows how to set up some profile fields.

let settings = AACUserSettings()
// Set up some basic profile fields.
settings.externalID = "an external ID" = "John Smith" = ""

AACSDK.updateUser(settings) { result ->
// do something with the callback result here

Setting up custom profile fields

You can also set up your custom fields of the user profile. Custom fields must first be created in Atomic Workbench before you can update them. For more details of custom fields, see Custom Fields.

There are two types of custom fields: date and text. Use AACUserSettings.setDateForCustomField(date, customField) for date fields and AACUserSettings.setTextForCustomField(text, customField) for text fields.

Note: Use the name property in the Workbench to identify a custom field, not the label property.

The following code snippet shows how to set up a date and a text field.

userSettings.setDateForCustomField(, "dateField")
userSettings.setTextForCustomField("test", "testfield")

Setting up notification preferences

You can use the following optional property and method to update the notification preferences for the user. Again, any fields which have not been supplied will remain unmodified after the user update.

  • notificationsEnabled: An optional boolean to determine whether notifications are enabled. The default notification setting of a user is true.
  • setNotificationTime(timeframes: List<AACUserNotificationTimeframe>, weekday: NotificationDays): An optional method that defines the notification time preferences of the user for different days of the week. If you specify NotificationDays.default to the weekday parameter, the notification time preferences will be applied to every day.

Each day accepts an array of notification time periods, these are periods during which notifications are allowed. If an empty array is provided notifications will be disabled for that day.

The following code snippet shows how to set up notification periods between 8am - 5:30pm & 7pm - 10pm on Monday.

val userSettings = AACUserSettings()
val timeFrames = listOf(
AACUserNotificationTimeframe(8, 0, 17, 30),
AACUserNotificationTimeframe(19, 0, 22, 0)

userSettings.setNotificationTime(timeFrames, AACUserSettings.NotificationDays.mon)

Hours are in the 24h format that must be between 0 & 23 inclusive, while minutes are values between 0 & 59 inclusive.

UpdateUser method: full example

The following code snippet shows an example of using the updateUser method to update profile fields, custom profile fields and notification preferences.

val userSettings = AACUserSettings() = "Test User" = "TestVille" = "Testmania"
userSettings.region = "Testonia" = "" = "555-1234"

userSettings.setTextForCustomField("test", "testfield")
userSettings.setTextForCustomField("test 2", "testfield2")
userSettings.setDateForCustomField(, "dateField")

userSettings.notificationsEnabled = true

val timeFrames = listOf(
AACUserNotificationTimeframe(8, 0, 17, 0),
AACUserNotificationTimeframe(19, 0, 22, 0)

userSettings.setNotificationTime(timeFrames, AACUserSettings.NotificationDays.mon)

AACSDK.updateUser(userSettings) { result ->
when (result){
is AACSDKSendUserSettingsResult.DataError -> { // do something with error
is AACSDKSendUserSettingsResult.Success -> { // do something
Optional values

Though all fields of AACUserSettings are optional, you must supply at least one field when calling AACSDK.updateUser.

Observing SDK events

(introduced in 23.3.0)

The Atomic Android SDK provides functionality to observe SDK events that symbolize identifiable SDK activities such as card feed changes or user interactions with cards. The following code snippet shows how to observe SDK events.

AACSDK.observeSDKEvents {
// do something with returned events

To stop observing, just assign null to observeSDKEvents

The SDK provides all observed events in the class AACSDKObserverEvent. An event has a corresponding eventType property taken from AACEventName enum class. The payload for each event is different and dependant on the eventType, but they closely follow Atomic analytics events. For detailed information about these events, please refer to Analytics reference.

Each event shares common information such as an eventName, timestamp, indentifier, and where appropriate, userId and containerId.

Below is a table of events, with the payload properties that are relevant for that event:

Event namePayload properties
UserRedirectedcardContext.cardViewState, properties.url, properties.payload
CardVotedDowncardContext.cardInstanceId, properties.reason, properties.message
RequestFailedproperties.path, properties.statusCode
CardSubviewExitedproperties.subviewId, properties.subviewLevel, properties.subviewTitle
CardSubviewDisplayedproperties.subviewId, properties.subviewLevel, properties.subviewTitle
SubmittedcardContext.cardInstanceId, properties.payload
DismissedSame as below
CardDisplayedSame as below
CardVotedUpSame as below
SnoozeOptionsDisplayedSame as below
SnoozedcardContext.cardInstanceId, properties.payload("unsnooze")

An example of a function callback to process events and their payloads

  private fun logEventMessage(event: AACSDKObserverEvent) {
val payload = StringBuilder()
payload.append("TimeStamp: ${event.timestamp} ")
payload.append("EventId: ${event.identifier} ")
payload.append("UserId: ${event.userId} ")
payload.append("ContainerId: ${event.sdkContext.containerId ?: ""} ")

when (event.eventName) {
AACEventName.UserRedirected -> payload.append("viewState: ${event.cardContext?.cardViewState} redirect: ${} payload: ${} ")
AACEventName.RuntimeVarsUpdated -> payload.append("runtimevars: ${ ?: ""}")
AACEventName.CardVotedDown -> payload.append("card Id: ${event.cardContext?.cardInstanceId} reason: ${} message:${} ")
AACEventName.RequestFailed -> payload.append("path: ${} statusCode: ${} ")
AACEventName.VideoPlayed -> payload.append("url: ${} ")
AACEventName.VideoCompleted -> payload.append("url: ${} ")
AACEventName.CardSubviewDisplayed -> payload.append("subViewId: ${} level: ${} subviewTitle: ${} ")
AACEventName.Submitted -> payload.append("card Id: ${event.cardContext?.cardInstanceId} payload: ${}")
AACEventName.Dismissed, AACEventName.CardDisplayed, AACEventName.CardVotedUp,
AACEventName.SnoozeOptionsDisplayed, AACEventName.SnoozeOptionsCanceled -> payload.append("card Id: ${event.cardContext?.cardInstanceId} ")
AACEventName.Snoozed -> payload.append("card Id: ${event.cardContext?.cardInstanceId} unsnoozeDate: ${"unsnooze") ?: ""} ")
AACEventName.CardFeedUpdated -> payload.append("card count: ${event.cardCount} ")
else -> {} // no payload outside of common

Log.d("OBSERVE MESSAGE PAYLOAD", "Payload: $payload")

Utility methods

Debug logging

Enable debug logging to view verbose logs of activity within the SDK, printed to the device’s console. Debug logging is disabled by default, and should not be enabled in release builds.


The parameter level is an integer that indicates the verbosity level of the logs exposed:

  • Level 0: Default, no logs exposed
  • Level 1: Operations and transactions are exposed
  • Level 2: Operations, transactions and its details are exposed, plus level 1.
  • Level 3: Internal developer logs, plus level 2


Logout will effectively end the user's session. It will clear theme and card caches, send any pending analytics events to the platform, and then log out the current user. The session delegate will also be reset and SDK settings cleared, which will cease any network traffic.

To logout, call:

AACSDK.logout(() -> {});

Since SDK v1.3.4 logout has an additional boolean parameter called deregisterDeviceForNotifications. This will also deregister the device for push notifications on logout if the parameter is true. The parameter defaults to false and can be set optionally.

AACSDK.logout(true, () -> {});
Switching users

If your application allows switching between users or user roles, it is recommended that you wait until the logout callback has returned before logging in a new user.

Notifying the SDK of background and foreground states

If your app does not initialise the SDK with observerProcessLifecycleOwner set to true in the init function, you can notify the SDK that your app has entered the background or resumed to the foreground using the following methods:

// your app is now in the foreground
// your app has been backgrounded

Setting the version of the client app

The SDK provides a method AACSDK.setClientAppVersion for setting the current version of your app. An app version is used with analytics to make it easy to track issues between app versions and general analytics around versions.

Version strings longer than 128 characters will be trimmed to that length.

From Atomic SDK 1.2.0, the client app version defaults to unknown if you do not call this method.

The following code snippet sets the client app's version to Version 14.2 (14C18).

AACSDK.setClientAppVersion("Version 14.2 (14C18)");

Managing system-initiated process death

On Android, the system may kill your app process while it is in the background to free up resources for other apps. The Atomic SDK requires configuration that can not be automatically restored after the process is recreated, for example, the authentication delegate, the application context, and stream container configuration. To prevent crashes after your app is restored, and to ensure that the SDK functions correctly after process death, there are some guidelines you must follow.

  1. Always call the AACSDK.init(context) method in the Application class of your app.

When the application is restored after process death, activities may be recreated in a different order to the usual flow of the app. For example, if you currently initialize the SDK in a login Activity that is part of a flow, when the app is recreated the Atomic SDK may be visible, but the code to initialize it may not have been executed. This can cause the SDK to raise exceptions, crashing your app.

  1. Store the AACStreamContainer objects in the ViewModel, and check for their existence when creating your activity or fragment.

AACStreamContainer objects should be persisted in memory across configuration changes, this will avoid unnecessary work such as extra calls to subscribe to the Atomic platform. However, whether you use ViewModels, or another in-memory persistence technique such as dependency injection, after system initiated process death these references will be cleared. Android, however, will still attempt to recreate the UI of the stream containers or single card view. This may lead to a situation where there is a visible, but non-functional stream container underneath the recreated container.

To prevent this, in the onCreate method of your Activity or Fragment. Check for the existence of the in-memory AACStreamContainer object and call the super.onCreate(savedInstanceState) method with the parameter null when the AACStreamContainer object is null. For example.

override fun onCreate(savedInstanceState: Bundle?) {
if (viewModel.streamContainer == null) {
} else {
// Creates the container, and stores it in a nullable property in the ViewModel.
// Then calls the start() method to show it in the UI
  1. Test that your application works correctly after system initiated process death.

Simulating system-initiated process death can be done using the ADB cli. To do this, launch your application from Android Studio. Navigate to the Atomic stream container in your app, then place your app in the background.

Open the terminal and call this command, replacing com.yourapp.applicationId with the applicationId of your app.

adb shell am kill com.yourapp.applicationId

Re-open your app from the app switcher, it should gracefully re-open and work as usual. The Atomic SDK will not retain form state or position in the UI after process death, subviews and media activities will be closed.

If the app crashes immediately after re-opening, ensure you are following the advice above and investigate the LogCat output to determine the cause of the problem. If this is your first time testing system-initiated process death in your app there may be other components that do not handle this scenario gracefully. Try removing Atomic to see if the issues persist.

If you still have issues after following these recommendations, please contact our support team.

Image linking to a URI

We've added support for a new feature on image elements in an Atomic cards which allows a user to navigate to a URI such as a webpage, open a card subview, or send a custom payload to your app when clicked.

This feature is currently in preview in the AtomicWorkbench. From the card builder add an image element to your card. Click on Edit and select the Link tab in the Action modal. Select the Link tab and choose the appropriate link action. For example to redirect to a webpage fill out the URL for each platform you wish it to apply to. Once rendered, the image element should redirect to the URL specified when clicked.

Card maximum width

We've added a new configuration property called cardMaxWidth. This is an additional feature to restrict the width of the card.

  • It's applicable to both vertical containers and single card views.
  • If cardMaxWidth is larger than the screen width, it will be ignored and the container's width will be used.
  • If cardMaxWidth is set to zero or a negative number, the value will also be ignored and the container's width will be used.
  • The default value of cardMaxWidth is zero and will use the container's width.
  • The value specified for cardMaxWidth is in pixel.
AACStreamContainer streamContainer = AACStreamContainer.create("1234");

Dependency graph

Our transitive dependency graph is listed below (current as of release 23.4.3 of the Android SDK):


Known issue and workaround

  • Proguard compilation issue
Verifier rejected class com.atomic.actioncards

If you come across the mentioned exception during compilation, it's likely due to ProGuard in your configuration. Depending on your Kotlin and ProGuard versions, you might face problems with classes that contain synchronized statements inside try-catch blocks. One workaround is to include the following in your ProGuard rules.

-keep class com.atomic.actioncards.** { *; }