'How to change default input language in TextInputEditText java Android

Help me to understand. Java Android My application has support from API 23 to 32. If API 24-29 then to change the default language you need to write:

TextInputEditText editText = findViewById(R.id.edit_text);

    if (Build.VERSION.SDK_INT >= 24 && Build.VERSION.SDK_INT <= 29) {
        editText.setImeHintLocales(new LocaleList(new Locale("ar", "SA")));
    }

But what to do when API 23 and > 29

If the keyboard is set to the desired language, say Arabic. When the user clicks on the edittext, the Arabic layout should open by default. Now if you switch to Arabic and reset the cursor from the edittext, then when you click again, the English language opens (again)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source