How to display a screen

In this section, you will find how to display a server-driven screen.

Display a screen through a URL

To display a full server-driven screen, you need to use the method this.newServerDrivenIntent<BeagleActivity>().

  • this refers to the context of the screen.

This method requires the parameter ScreenRequest.

You must follow the example below:

val intent = this.newServerDrivenIntent<BeagleActivity>(ScreenRequest("/screen"))
startActivity(intent)

The Screen Request class.

The ScreenRequest is an internal Beagle class used to request which screen you want to display. You will only list the URL attribute for the page you want to load from the BFF. However, this element has other attributes, which can be used in the transition and between screens.

To learn more about this class, check out on Screen Request

Display a screen through a JSON

To render any Beagle component in Android, it’s necessary to inform a viewGroup where the view corresponding to the component will be rendered, such as a FrameLayout within an Activity, Fragment or DialogFragment. See the example below:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frame_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"/>

Now, call the loadView() method from the frame_layout created in the xml and pass the Activity and the JSON as parameters.

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        frame_layout.loadView(
            activity = this,
            screenJson = "JSON HERE"
        )
    }
}

Last modified September 20, 2021: Review android 1.10 (#776) (1a04515a)