How can I check If Keyboard is open or not in Appi

2020-05-09 18:01发布

问题:

I am trying to check, if android default keyboard is open or not. I did not find anything to check keyboard using JAVA and ADB command in Appium.

回答1:

I have found this ADB command to check keyboard is opened or not.

adb shell dumpsys input_method | grep mInputShown

In output mInputShown=true if keyboard is open and mInputShown=false if keyboard is closed. JAVA code:

String cmd[] = new String[]{"adb", "shell", "dumpsys", "input_method", "|" ,"grep", "mInputShown"};
Process process = Runtime.getRuntime().exec(cmd);    
BufferedReader reader = new BufferedReader(new InputStreamReader(        
process.getInputStream()));
String output = reader.readLine();


标签: java adb appium