0

I have a rooted device where I am checking if the soft keyboard is visible by executing this adb command in the terminal:

adb shell dumpsys window InputMethod | grep "mHasSurface"

and this is the output:

mHasSurface=true mShownPosition=[0,1176] isReadyForDisplay()=true hasSavedSurface()=false mWindowRemovalAllowed=false

I am able to execute the same adb command from my app (using root) but I don't know how to get the output. Does anyone know if its possible to get the output in app? Thank you in advance.

android enthusiast
  • 2,062
  • 2
  • 24
  • 45
  • could you please post the code you're using to execute the same command in your app? – Lino Jul 12 '20 at 08:17

1 Answers1

0

After a while, found a way to do it here:

            try {
                Process process = Runtime.getRuntime().exec(sCommand11);
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                int status = process.waitFor();
                Timber.d(sSUCommand6 + " finished with status " + status);

                // Grab the results
                StringBuilder log = new StringBuilder();
                String line;
                while ((line = bufferedReader.readLine()) != null) {
                    log.append(line + "\n");
                }

                Timber.d("We have the input " + log.toString());

            } catch (Exception e) {
                Timber.e("Error occurred while copying file " + e.getMessage());
            }
android enthusiast
  • 2,062
  • 2
  • 24
  • 45