Getting device's keyboard status with Java

Does anyone knows if there is a way to find out the status of the device’s keyboard: whether it appears or hidden.

iOS or Android? this is first question :slight_smile:

1 Like

Let’s start with Android, although eventually I will need them both. (-:

ok. here it is. depending what we start real device or genymotion emulator we use “d” or “e”.

public boolean isKeyboardLoaded_Android(String deviceName) {
String lsString;
String output = “”;
String[] cmd;
try {
cmd = new String[] {“sh”, “-c”, “adb -e shell dumpsys window InputMethod | grep “mHasSurface””}; // e = emulator, d = device
cmd = new String[] {“sh”, “-c”, “adb -d shell dumpsys window InputMethod | grep “mHasSurface””};
Process process = Runtime.getRuntime().exec(cmd);
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
while ((lsString = bufferedReader.readLine()) != null) {
output = output + lsString;
} catch (Exception e) {
System.out.println(" isKeyboardLoaded_Android output:\n"+output);
return output.contains(“isReadyForDisplay()=true”);

1 Like