Android app - show "Change Keyboard" settings dialog - java

I am developing an android app in Java that needs to be set up as a keyboard.
I want to have a button that when the user presses my app shows the following dialog box:
This is a quick settings dialog box to allow the user to choose the input method (keyboard) it wants to use from now on. It is a default Android setting that is accessible to any user.
Normally this setting shows up when you press the following shortcut next to the android navigation bar when a keyboard is opened:
But in the context I am working on, this option is not visible to the user. So I want my app to be able to show this setting to the user when it presses a button.
I know an app that does this exact thing, so I know that it is possible. However, I don't know how to code a button that displays a system dialog box like this one.
Could you please help me?
Thanks in advance!

After some more research I found the answer using an InputMethodManager object and the showInputMethodPicker() method in Java:
InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
inputMethodManager.showInputMethodPicker();

Related

How can I disable/dismiss the keyboard on iOS with Appium

Is there anyway to dismiss the iPhone keyboard or disable it from popping up at all while Appium tests are being run?
driver.hideKeyboard() doesn't work, half the time a "DONE" or "RETURN" button isn't present and I can't just tap randomly on the screen because I can not guarantee that the code won't accidentally tap a link or active element.
I don't understand why it doesn't just function like on Android and just never display the keyboard when using driver.sendKeys().
I've noticed the same and did a workaround by doing it like an actual user and clicking on the hide keyboard button. You might want to add a check to only click if the element is visible to avoid trying to close the keyboard when it's not there.
driver.findElement(By.xpath("your_keyboard_close_button")).click();

how can I flip an android dialog on click?

I have an android dialog
I saw this tutorial for swiping a dialog in and out.
how can I filp a dialog when the user clicks on the dialog.
I want to actually show the user two dialog with different content and trasit with flip between them
Try using the code from google or combine it's xml if it works, saw also good example here

Android, how to show software keyboard on click

I have a dialog box in my Android app; it is the only EditText control on the dialog (the others are spinners and buttons), and so it gets focus when the dialog is shown. This prevents the on-screen keyboard from ever showing up, meaning you can't easily enter any text into the box unless you have a hardware keyboard.
I believe (but I couldn't swear to it) that this is because the control starts with focus, and the system check as to whether to show the keyboard or not happens in the onfocus event. Is there any way the programmatically show the on-screen keyboard?
In order to implement the ability to force the keyboard open when the user presses a button on the screen then the following should help.
InputMethodManager inputMethManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethManager.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
However an alternative to help regain focus of the dialog window can be found below. This code should open the software keyboard for you by resetting any flags initially set by AlertDialog. This code should be placed after the creation of the dialog window.
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

Why doesn't the virtual keyboard go away?

I have a pretty simple screen with a couple of EditText widgets and a button. In the emulator, when I click on the EditText widget, a virtual keyboard comes up. However, I can't seem to get rid of it. Clicking on an empty space on the screen does not make it go away. Only clicking the virtual Return key or the hardware Back button makes it disappear.
I don't have a real Android phone handy, so is this an emulator only thing or will it be like this on the actual device. If it is, what can I do to make the virtual keyboard go away, when I click elsewhere on the form?
Click the back button. They keyboard is an activity. There's not an easy way to remove the keyboard when clicking on a random area of the screen.
AngryHacker , I woud refer you to this post how to close/hide the android soft keyboard.
Hope this helps.
I think in the emulator you can press Escape to hide the keyboard. On a real device there is a hide button on the keyboard or you can press elsewhere in the ui. That's how it works on my HTC Desire S anyway.
I lived this problem and i resolved it. This problem is about InputMethodManager.SHOW_FORCED value in my project. When i open keypad using SHOW_FORCEDthen when i try to close keypad, keypad was not closing.
For Example :
activity.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, InputMethodManager.SHOW_FORCED);
If you use above way to open keypad, you may try to change SHOW_FORCED value with SHOW_IMPLICIT value
For Example :
activity.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
I have the Galaxy S2 which is running Andriod 2.3.6.
I was having issues with the keyboard not moving out of the way after entering the needed text when logging into websites. I found that hitting the hardware return button does take the virtual keyboard out of the way. But occassionally it will take the web browser back one page. Which is frustrating because then I have to re-enter the log in info for whatever web site I'm connecting too. Hopefully Android 4.x has solved some of these glitchy issues.
You can achieve this by doing the following steps:
Make the parent view(content view of your activity) clickable and focusable by adding the following attributes
android:clickable="true"
android:focusableInTouchMode="true"
Implement a hideKeyboard() method
public void hideKeyboard(View view) {
InputMethodManager inputMethodManager =(InputMethodManager)getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
}
Lastly, set the onFocusChangeListener of your edittext.
edittext.setOnFocusChangeListener(new View.OnFocusChangeListener() {
#Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
hideKeyboard(v);
}
}
});
Source

How to detect when Android software keyboard is hidden?

I need to detect when the android software keyboard is hidden. My activity currently responds to when the hardware keyboard is hidden but the software keyboard looks like it can only be implied through a size changed event.
Does anyone know of a way that a view or activity can receive a notification when the software keyboard is hidden by the user cancelling out of keyboard mode?
Would forcing the sof tkeyboard to always be visible help?
You can add this to your Activity's xml file to ensure the softkeyboard is always visible in that Activity:
android:windowSoftInputMode="stateAlwaysVisible"
http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
Theres no real way to check, but you can check if an action on it works or not
boolean isClosing = false;
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
isClosing = imm.hideSoftInputFromWindow(tabHost.getApplicationWindowToken(), 0);
This will return false if the keyboard was closed and true if it was open and is now being closed.
I solved this by just searching for the back key. When the back key is received I know that the soft keyboard will be cancelled.

Categories

Resources