setSystemLocale

fun setSystemLocale(locale: Locale)

Sets locale as the Android System Locale. This can be used to switch language on the Android system level. The android.permission.CHANGE_CONFIGURATION permission is required in order to use this API.

If the system Locale is changed, Android system will apply a configuration change. Typically, this results in the Android Activity to be restarted. If the locale is not supported by the Android system because of an invalid language or region code, the typical behavior of the Android system is to fallback to US English. If locale is the same as the current system Locale, no change will take effect.

Note: This API only supports:

  • compileSdk: API Level 31.

  • targetSdk: API Level 27.

  • minSdk: API Level 27.

Parameters

locale

a Locale initialised with the desired language and region.