# In-app Language Switches

The Live2.ai Android SDK supports the host app in dynamically changing languages at runtime. There are no specific API requirements for the host app to leverage this feature. The host app can implement its own mechanism for overriding the context, and the Live2.ai Android SDK will automatically update the **`PlayerActivity`'s `BaseContext`** to the desired locale. This update ensures that resources and layout alignment (LTR/RTL) reflect the current locale.

```kotlin
Kotlin:

class InAppLanguageActivity : FragmentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_in_app_language)
    }

    override fun attachBaseContext(newBase: Context) {
        super.attachBaseContext(LanguageHelper.changeLanguage(newBase))
    }

    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
        menuInflater.inflate(R.menu.in_app_toolbar, menu)
        return true
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        return when (item.itemId) {
            R.id.menu_en -> handleLanguageChange(getString(R.string.in_app_language_en))
            R.id.menu_hi -> handleLanguageChange(getString(R.string.in_app_language_hi))
            R.id.menu_de -> handleLanguageChange(getString(R.string.in_app_language_de))
            else -> super.onOptionsItemSelected(item)
        }
    }

    private fun handleLanguageChange(languageCode: String): Boolean {
        LanguagePreference.setLocalePreference(this, languageCode)
        recreate()
        return true
    }
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.live2.ai/live2.ai-integration/in-app-language-switches.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
