My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Supporting Views and Fragments in Zabaan Android SDK

Supporting Views and Fragments in Zabaan Android SDK

Karan  Mer's photo
Karan Mer
·Oct 7, 2021·

2 min read

Zabaan is Navana Tech's layer-on-top digital assistant that comes packaged as a light-weight SDK. It provides localized audio-visual instructions to end users in any language or dialect.

Zabaan in Action

Zabaan in Action

In older versions of Zabaan SDK < 1.2.0 showing the Assistant would require an instance of the activity on which the assistant is to be displayed. As a result, the assistant' lifecycle was tightly bound to each activity' life cycle. This worked will for multi-activity architectures. However, most standards in Android developed have now adopted the single activity architecture pattern.

The major issue with implementing Zabaan in a single activity app architecture was that the previous activity based implementation restricted us from being able to monitor lifecycle changes of the fragment (or any view for that matter). As a result, we required manual intervention by the implementing developer to inform us of lifecycle changes so we could do the necessary state management for the assistant.

Zabaan SDK would not have been able to support apps which use view based system instead of Activity or Fragment.

Our first attempt to address this issue was to provide cleanup methods to implementing developers, allowing them to have more control of Zabaan state. This solution still relied on implementing developer intervention. Not to mention, if cleanup protocols were not followed correctly, it could lead to memory leaks in their app.

Instead we changed the way implementing developers are able to embed the assistant in their app. However, this posed a challenge of ensuring that existing live versions of the SDK did not become incompatible. We didnt want any of our existing users to suddenly see broken code! To make this more subtle and intuitive we marked the existing method as deprecated and created a new show function which takes 2 arguments, the root view and the lifecycle, thus allowing us to inflate the assistant in an activity, a fragment or any view based system for that matter. This also allowed us to monitor lifecycle changes and take care of all clean up tasks within the SDK. This led to us providing a better experience to any implementing developer while improving on the performance and occurrence of memory leaks in the implementing app.

Previous method signature

fun show(activity: AppCompatActivity)

Previous call site code (In activity)

Zabaan.getInstance().show(this)

New method signature

fun show(rootView: View, lifecycle: Lifecycle)

Call site code

Zabaan.getInstance().show(viewBinding.rootView, lifecycle)

To know more about what Zabaan SDK is and what it does, please visit our website. You can also watch quick youtube video guide for getting started with Zabaan SDK here.