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
WebView
viagetView()
.- In a View-based UI, you add this
WebView
into your layout. - In Jetpack Compose, you use
AndroidView
to host theWebView
.
- In a View-based UI, you add this
- 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.RawLink("https://demo.expofp.com")
)
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.RawLink("https://demo.expofp.com")
)
setContent {
AndroidView(factory = { presenter.getView() })
}
}
}
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(URLQueryItem("noOverlay", "true"))
val locationProvider: IExpoFpLocationProvider = YourLocationProvider()
val messageListener: IExpoFpPlanMessageListener = YourMessageListener()
val presenter = ExpoFpPlan.createPlanPresenter(
planLink = ExpoFpLinkType.ExpoKey(expoKey),
additionalParams = additionalParams,
locationProvider = locationProvider,
messageListener = messageListener
)