Switch keyboard profile programmatically
This piece of code will fulfill your requirements:
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
imeManager.showInputMethodPicker();
As Commonsware points out in his answer, there is no way to do this behind the user's back.
Programmatically enabling a custom keyboard
Just open input method settings activity
using Intent
.
Intent enableIntent = new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS);
enableIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(enableIntent);
How to get this dialog to change the keyboard android programmatically
InputMethodManager imeManager = (InputMethodManager)
getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
imeManager.showInputMethodPicker();
Programmatically change Keyboard Layout
Use this command
powershell -command "Set-WinUserLanguageList -Force 'en-US'"
or
powershell -command "Set-WinUserLanguageList -Force 'fr-FR'"
Change keyboard language programmatically
There is a big work around about how to do this - which is create your own keyboard, and to do this you'll have to know the keyboards you're aiming for. (which will be exact duplicate of the regular keyboard)
General guide on the subject here & code samples.
Create a custom keyboard View which extends keyboardView
In it create static key value variable like
static final int KEYCODE_LANGUAGE_SWITCH_ENG = -102;
static final int KEYCODE_LANGUAGE_SWITCH_URDU = -103;
after that in your IME class where you have implemented the inputMethodService, create the keyboards inside the onInitializeInterface override function. like
mSymbolsKeyboard = new Keyboard(this, R.xml.qwerty2);
mEngQwertyKeyboard = new Keyboard(this, R.xml.eng_qwerty);
after this add these final static keys in the onKey override function as switch cases, and in the cases set the keyboards accordingly:
setKeyboard(mEngQwertyKeyboard);
Related Topics
Apk Location in New Android Studio
Cannot Catch Toolbar Home Button Click Event
Android Layout Folders: Layout, Layout-Port, Layout-Land
Check Whether Activity Is Active
Implementing Text Watcher for Edittext
Autoincrement Versioncode with Gradle Extra Properties
Fragments Destroyed/Recreated with Jetpack's Android Navigation Components
Android Recording Incoming and Outgoing Calls
Generate Signed APK Android Studio
Android Edittext Onchange Listener
Android: Unable to Instantiate Activity/Classnotfoundexception
How to Get the Position Selected in a Recyclerview
How to Create Android Spinner Without Down Triangle on the Right Side of the Widget
Customize Check Box Preference
Adb Server Is Out of Date. Killing
ASP.NET Web API Authentication
What Do Gc_For_Malloc, Gc_Explicit, and Other Gc_* Mean in Android Logcat