Skip to main content

Android - UI Module Interface

note

To call a UIModule, a Tecton Caliper extension is required. Please refer to the Caliper guides to get started.

The UIModule interface is used when creating a module that requires a displayed UI. This is ideal when you need to create your own Activity to host custom views.

This module provides minimal required overrides, allowing full control over the user experience.

Implementation

Implementing a UIModule is straightforward—create your own Activity and inherit the interface. From there, you can freely create your own views. When finished, call finish() to return to the previous screen.

Sample UIModule Implementation
class UIModuleTestClass(private val sdkUtils: SdkUtils) : UIModule {
override fun start(activity: Activity?, data: JSONObject?, activityRequestCode: Int) {
activity?.let {
val intent = UIModuleTestActivity.getIntent(it, sdkUtils)
it.startActivityForResult(intent, activityRequestCode)
}
}
override fun stop() {}
}

class UIModuleTestActivity : AppCompatActivity() {

private lateinit var sdkUtils: SdkUtils

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_test)

sdkUtils = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableExtra(EXTRA_SDK_UTILS, SdkUtils::class.java)!!
} else {
intent.getParcelableExtra(EXTRA_SDK_UTILS)!!
}
}

companion object {
private const val TAG = "UIModuleTestActivity"
private const val EXTRA_SDK_UTILS = "EXTRA_SDK_UTILS"

fun getIntent(context: Context, sdkUtils: SdkUtils): Intent {
val intent = Intent(context, UIModuleTestActivity::class.java)
intent.putExtra(EXTRA_SDK_UTILS, sdkUtils)
return intent
}
}
}

Triggering From Tecton

To call your UIModule, follow the Tecton - openModule guide.

Update Your settings.json

Ensure your settings.json file in the root of the DevApp is updated to reflect your module changes. Learn more in Configuring settings.json.