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

2020-05-09 17:39发布

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.

标签: java adb appium
1条回答
Emotional °昔
2楼-- · 2020-05-09 18:24

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();
查看更多
登录 后发表回答