Skip to content

Setting screen name and using State


Zabaan SDK uses the concept of screen and state to identify and set interactions needed to be played for a particular screen and state.

To identify a particular screen setScreenName(screen_name) must be used. Make sure to call this function inside onResume(). Each interaction defined over the CMS should have a state defined.

@Override
protected void onResume() {
        //This tells Zabaan which screen is currently active
        Zabaan.getInstance().setScreenName("ScreenName");
        //This tells Zabaan which state is active on any given screen
        Zabaan.getInstance().setCurrentState("DefaultState")
}

Check this video for more information

Using multiple states

On any Activity/Fragment, you may want the assistant to play different audio based on particular criteria. For example, if a user has not used a particular feature you could assign them a particular state feature_not_used

However, if they have used that feature you could assign them feature_used state.

These states will talk to our back-end and retrieve the appropriate audio to play to the user.

if(feature_used)
    Zabaan.getInstance().setCurrentState("feature_used")
else
    Zabaan.getInstance().setCurrentState("feature_not_used")

Now, once the user clicks on the Zabaan Assistant, the audio will play based on the state assigned.

Using states as triggers

All of the above applies to a scenario in which a user requests help by clicking on the Assistant icon. If a user makes a mistake while interacting with a particular element on the screen, we provide the ability to play an audio file in the following manner:

//User inputting the incorrect four digit pin
if(invalid_four_digit_pin) {
    StateInteractionRequest request = new StateInteractionRequest.Builder()
        .setState("invalid_four_digit_pin")
        .build();
  Zabaan.getInstance().playInteraction(request);
}

Check this video for more information

Highlighting views dynamically

For scenarios where the application has to decide at run-time which view they should point to, the below solution can be used. By using the function playInteraction(ViewOnlyInteractionRequest). Users can also choose from a variety of finger animations to use by using the setFingerAnimation function.

ViewInteractionRequest request = new ViewInteractionRequest.Builder()
    .setViewId(String.valueOf(R.id.img_add))
    .setFingerAnimation(AnimationSwipeLeftNormal.INSTANCE)
    .setState("SPECIAL_STATE")
    .build();
Zabaan.getInstance().playInteraction(request);

Check this videos for more information

Back to top