Initialization - Fragment Standard Experience

Embed the SDK in your own Activity as a Fragment, keeping your Activity lifecycle uninterrupted.

Fragment Standard Experience Initialization

The PayMitto SDK can run inside your own Activity as a Fragment, instead of launching a new Activity. This is the recommended approach when you need your Activity to remain in the RESUMED state while the SDK is running — for example, when you have coroutines, LiveData observers, or custom modals tied to your Activity's lifecycle.

Once you have created the PayMittoConfiguration object, call createFragment from the PayMitto singleton. Authentication is performed before onFragmentReady is called. Add the fragment to your FragmentManager inside the callback.

PayMitto.createFragment(
    activity = this@MainActivity,
    readyRemitConfiguration = sdkConfiguration
) { fragment ->
    supportFragmentManager.beginTransaction()
        .replace(R.id.container, fragment)
        .addToBackStack(null)
        .commit()
}

ℹ️

Edge-to-edge

When using the Fragment API, your Activity is responsible for calling enableEdgeToEdge() if you want the SDK visuals to extend behind the system bars.


ℹ️

Locale

In Fragment mode, display strings follow your host Activity's locale. The localization parameter in PayMittoConfiguration still controls the API request language (Accept-Language header) and date formatting.


ℹ️

If you are using Jetpack Compose

Don't create the configuration object or call PayMitto.createFragment in the compose scope, since recompositions lead to runtime errors.

You must create the configuration object inside a remember clause or in an AndroidX ViewModel.



Did this page help you?