Android Behaviours

Launch an Experience as an Android Activity or Fragment

Aiming to provide the most flexibility we can, we have also wrapped our ExperienceView in an Activity and Fragment so you can leverage all the functionality Android provides within those two classes.

When using ExperienceActivity and ExperienceFragment, custom loading and error view providers are not supported as we can't parcelise the provider functions.

Instead, use an ExperienceView, or wrap it with your own Fragment or Activity.

You can use them by following the next snippets:

val experienceIntent = Launcher.default.getExperienceIntent(context)

startActivity(experienceIntent)

Listen to touch events in the Experience on Android

If you want to react to how users scroll through the app, e.g. in order to collapse a toolbar, we offer the possibility to provide an OnTouchListener that forwards you the user interactions with the Experience. You can register it like so:

val experienceView = Launcher.default.getExperience(context, config)

experienceView.experienceOnTouchListener = View.OnTouchListener{ view, motionEvent ->
    // React to touch events
}

Enable fullscreen videos on Android

To enable an app to host videos full screen in Android, you'll need to provide an Activity instance following the next snippet:

val experienceView = Launcher.default.getExperience(context, config)

experienceView.allowFullScreenVideosInActivity(activity = this)

Last updated