White-label App SDK
API Reference
HeadlessActivity

HeadlessActivity

Overview

The HeadlessActivity class extends ComponentActivity and provides essential methods for handling the lifecycle and interactions of a SoftPOS transaction activity. This includes managing the UI state, handling NFC operations, and providing themes and UI components.

Methods

provideTheme

Override to provide the theme color for the activity.

Returns

Return TypeDescription
ThemeProviderThe custom theme provider.

Usage

import android.graphics.Color
import com.theminesec.sdk.headless.HeadlessActivity
import com.theminesec.sdk.headless.ui.ThemeProvider
 
class ClientHeadlessImpl : HeadlessActivity() {
    override fun provideTheme(): ThemeProvider = CustomThemeProvider
}
 
object CustomThemeProvider : ThemeProvider() {
    override fun provideColors(darkTheme: Boolean): HeadlessColors = if (darkTheme) {
        HeadlessColorsDark().copy(
            primary = Color.CYAN,
            primaryForeground = Color.BLACK,
            secondary = Color.BLUE,
            secondaryForeground = Color.BLACK,
            approval = Color.GREEN,
            approvalForeground = Color.WHITE,
            error = Color.RED,
            errorForeground = Color.WHITE
        )
    } else {
        HeadlessColorsLight().copy(
            primary = Color.CYAN,
        )
    }
}
 

provideUi

Provides the UI components for the activity.

Returns

Return TypeDescription
UiProviderThe custom UI provider.

Usage

override fun provideUi(): UiProvider = CustomUiProvider()

You can provide the UI with Compose or as an inflated traditional XML view, for more details, see:

Companion Object

contract

Creates an activity result contract for starting the HeadlessActivity.

Parameters

ParameterTypeConditionDescription
clsClass<out HeadlessActivity>RequiredThe class of your custom HeadlessActivity.

Returns

Return TypeDescription
ActivityResultContract<PoiRequest, WrappedResult<Transaction>>The activity result contract for the request PoiRequest and wrapped response WrappedResult<Transaction>.

Usage

val contract = HeadlessActivity.contract(MyHeadlessActivity::class.java)
val launcher = registerForActivityResult(contract) { result ->
    when (result) {
        is WrappedResult.Success -> {
            // Handle success
            val transaction = result.value
        }
        is WrappedResult.Failure -> {
            // Handle failure
            val errorCode = result.code
            val errorMessage = result.message
        }
    }
}
 
// Start the activity with a PoiRequest
val poiRequest = PoiRequest.ActionNew(/* initialize with appropriate parameters */)
launcher.launch(poiRequest)