Skip to content

Load and Show Plan

This section explains how to load and display a plan using the SDK.

Overview

  • A plan is managed by a presenter created with ExpoFpPlan.createPlanPresenter(...).
  • The presenter provides a View via getView(). It is a self-sizing container that fills its parent (not a WebView).
    • In a View-based UI, attach the presenter to an ExpoFpView.
    • In Jetpack Compose, host the View directly via AndroidView.
  • You can optionally provide additional parameters, a location provider, and a message listener.

Step 1. Initialize the SDK

Call ExpoFpPlan.initialize(context) once, usually in Application or the first Activity.

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    ExpoFpPlan.initialize(this)
}

Step 2. Minimal Example (View-based)

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        ExpoFpPlan.initialize(this)

        val presenter = ExpoFpPlan.createPlanPresenter(
          planLink = ExpoFpLinkType.ExpoKey("demo")
        )

        val expoView = ExpoFpView(this).apply {
            attachPresenter(presenter)
        }

        setContentView(expoView)
    }
}

Step 3. Minimal Example (Jetpack Compose)

class MainActivity : ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        ExpoFpPlan.initialize(this)

        val presenter = ExpoFpPlan.createPlanPresenter(
            planLink = ExpoFpLinkType.ExpoKey("demo")
        )

        setContent {
            AndroidView(
                factory = { presenter.getView() },
                modifier = Modifier.fillMaxSize()
            )
        }
    }
}

Note: getView() returns a self-sizing container that fills its parent, so you can host it directly in AndroidView. No manual FrameLayout wrapping is needed.


Step 4. Advanced Initialization

You can customize the presenter by passing additional parameters, a location provider, and a message listener.

val expoKey = "YourExpoKey"
val additionalParams = listOf(ExpoFpPlanParameter.NoOverlay(true), ExpoFpPlanParameter.HideHeaderLogo(true))
val locationProvider: IExpoFpLocationProvider = YourLocationProvider()
val messageListener: IExpoFpPlanMessageListener = YourMessageListener()

val presenter = ExpoFpPlan.createPlanPresenter(
    planLink = ExpoFpLinkType.ExpoKey(expoKey),
    additionalParams = additionalParams,
    locationProvider = locationProvider,
    messageListener = messageListener
)