When robotium is used for automated functional testing, some edittext and other virtual keyboard pop-up problems often lead to additional workload to handle the problem of the virtual keyboard. Now, specify a method to handle the virtual keyboard: Inputmethodmanager: Central system API to the overall input method framework (IMF) architecture, which arbitrates interaction between applications and the current input method. You can retrieve an instance of this interface with context. getsystemservice (). Inputmethodmanager is used to control the input method:
Java codeInputmethodmanager Imm = (inputmethodmanager) getsystemservice (context. input_method_service ); Use: Java code If (IMM. isactive ()) To check whether the virtual keyboard is enabled. Then you can use the toggle method to close its Java code. Imm. togglesoftinput (inputmethodmanager. show_implicit, inputmethodmanager. hide_not_always ); Of course, if the current virtual keyboard is disabled, toggle will enable the keyboard. Inputmethodmanager can also be enabled and disabled independently: Java code Imm. showsoftinput (view, flags ); Imm. showsoftinputfrominputmethod (token, flags ); Imm. hidesoftinputfrominputmethod (token, flags );
In robotium: Inputmethodmanager Imm = (inputmethodmanager) Solo. getcurrentactivity (). getsystemservice (context. input_method_service ); Asserttrue (IMM. isactive ()); |