> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How Does onConfigurationChanged() Work for In-App in Android Native?

> Understand how the onConfigurationChanged() lifecycle method interacts with MoEngage in-app campaigns in Android native apps.

## Problem

Native in-apps are limited to portrait mode when using`onConfigurationChanged()`, which prevents landscape orientation, whereas HTML in-apps support both orientations.

## Instructions

1. Open the [Handling Configuration](/docs/developer-guide/android-sdk/in-app-messages/in-app-nativ) link, change, and override the code in your activity or fragment.

```kotlin Kotlin wrap theme={null}
override fun onConfigurationChanged(newConfig: Configuration) {
  super.onConfigurationChanged(newConfig)
  MoEInAppHelper.getInstance().onConfigurationChanged()
}
```

<Info>
  **Information**

  This method notifies the MoEngage SDK when a configuration change occurs for an activity or fragment that Android does not handle.
</Info>

2. To manually manage configuration changes for an activity or fragment, you must add the `android:configChanges="orientation"` attribute to the relevant `<activity>` tag within your `AndroidManifest.xml` file.

```xml AndroidManifest.xml wrap theme={null}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    
    <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyApplication"
        android:usesCleartextTraffic="true"
        tools:targetApi="31">
        
        <activity
            android:name=".ui.MainActivity"
            android:configChanges="orientation"
            android:exported="true" /> 
        
    </application>

</manifest>
```

3. Run the Native app with this setup, call `showInApp()` in `onResume`, and the in-app will appear in its default portrait mode.

<Frame>
  <img src="https://mintcdn.com/moengage/kA1FMKEyetrXvCeI/images/3-2.png?fit=max&auto=format&n=kA1FMKEyetrXvCeI&q=85&s=d2ac67626d117c9f89d4bbdfd305b6a5" alt="3 2" width="508" height="1128" data-path="images/3-2.png" />
</Frame>

4. When orientation changes, the in-app disappears and displays `ORIENTATION_NOT_SUPPORTED` for the native in-app campaign.

<Frame>
  <img src="https://mintcdn.com/moengage/kA1FMKEyetrXvCeI/images/4-2.png?fit=max&auto=format&n=kA1FMKEyetrXvCeI&q=85&s=9d0ee69615400ad17f9d18ad8a6e14a5" alt="4 2" width="996" height="458" data-path="images/4-2.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/moengage/kA1FMKEyetrXvCeI/images/5-1.png?fit=max&auto=format&n=kA1FMKEyetrXvCeI&q=85&s=3a54476c0f1535fb3413f3c4e25d3e25" alt="5 1" width="1920" height="401" data-path="images/5-1.png" />
</Frame>

5. HTML in-apps support both portrait and landscape orientations. Internally, `onConfigurationChanged()` calls ConfigurationChangedHandler's `showInAppOnConfigurationChange()` of the HTML in-app.

<Frame>
  <img src="https://mintcdn.com/moengage/kA1FMKEyetrXvCeI/images/7-1.png?fit=max&auto=format&n=kA1FMKEyetrXvCeI&q=85&s=6eba69db99287680558b7e5916333d02" alt="7 1" width="478" height="1056" data-path="images/7-1.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/moengage/kA1FMKEyetrXvCeI/images/8.jpeg?fit=max&auto=format&n=kA1FMKEyetrXvCeI&q=85&s=3471c7f1b5bd8eaa5f4a0322a26bc97f" alt="8" width="1920" height="860" data-path="images/8.jpeg" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/moengage/kA1FMKEyetrXvCeI/images/9.png?fit=max&auto=format&n=kA1FMKEyetrXvCeI&q=85&s=9c93abfb514ac884a7392d27dba65420" alt="9" width="1024" height="24" data-path="images/9.png" />
</Frame>
