I am trying to answer an incoming phone call on android 5.0. I made a native (i.e., Java-only) test project and it worked! But when I call the same code from Qt, nothing happens despite a Process exit code of 0 (indicating success). Here is an excerpt of the relevant code:

Qt Code:
  1. new Thread(new Runnable() {
  2. public void run() {
  3. try {
  4. Process p = new ProcessBuilder("input", "keyevent",Integer.toString(KeyEvent.KEYCODE_HEADSETHOOK)).start();
  5. p.waitFor(); // if I don't do this, I get a java.lang.IllegalThreadStateException
  6. System.out.println("exitValue: " + p.exitValue()); //returned: 0
  7. System.out.println("error: " + p.getErrorStream()); // returned: java.lang.ProcessManager$ProcessInputStream@2548dfca
  8. } catch (Exception e) {
  9. e.printStackTrace();
  10. }
  11. }
To copy to clipboard, switch view to plain text mode 


I thought that maybe this was a Qt/Android threading issue, but according to my reading, calling Java from a JNI object should take care of that. Does anybody have any insight as to why my call is not answered?

Thank you very much!