Compose WebView Part 3 | Handle configuration changes

Handling an orientation change without reloading the page from source each time.

To manually handle orientation changes in your app you must declare the "orientation", "screenSize", and "screenLayout" values in the android:configChanges attributes. You can declare multiple configuration values in the attribute by separating them with a pipe | character.

WebView With Jetpack Compose in Android Studio | Kotlin | Jetpack Compose | Android Tutorials

For example, the following manifest code declares an activity that handles both screen orientation changes and keyboard availability change: (Use android:configChanges )

<activity android:name=".MyActivity"

we can  checks the current device orientation: using below code

 //The Configuration object represents all of the current configurations, not just the ones that have changed.
    val configuration = LocalConfiguration.current
    when (configuration.orientation) {
        Configuration.ORIENTATION_LANDSCAPE -> {
            Toast.makeText(context, "landscape", Toast.LENGTH_SHORT).show()
        else -> {
            Toast.makeText(context, "portrait", Toast.LENGTH_SHORT).show()


GET source code on Github: