Daniel Daniel - 4 months ago 56x
Android Question

Suppress keyboard after setting text with Android uiautomator

Using uiautomator for Android I am able to set text in a text field but not able to then close the keyboard. With some phones when in lanscape mode the keyboard takes up the whole screen and 'Done' must be tapped to get out of that view. If I can suppress the keyboard then I can run uiautomator in both landscape and portrait without issue.

new UiObject(new UiSelector().text("Enter Text")).click();
new UiObject(new UiSelector().className("android.widget.EditText").instance(0)).setText("sample text");

// This is where I need to suppress the keyboard to view the app instead of just the keyboard itself.

new UiObject(new UiSelector().text("Submit")).click();

Thanks in advance.


Normally clicking the Back-key will dismiss the keyboard.