How can I check If Keyboard is open or not in Appium using JAVA and ADB command

后端 未结 1 1462
花落未央
花落未央 2021-01-29 07:36

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条回答
  •  暖寄归人
    2021-01-29 08:15

    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();
    

    0 讨论(0)
提交回复
热议问题