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:
new Thread(new Runnable() {
public void run() {
try {
Process p = new ProcessBuilder("input", "keyevent",Integer.toString(KeyEvent.KEYCODE_HEADSETHOOK)).start();
p.waitFor(); // if I don't do this, I get a java.lang.IllegalThreadStateException
System.out.println("exitValue: " + p.exitValue()); //returned: 0
System.out.println("error: " + p.getErrorStream()); // returned: java.lang.ProcessManager$ProcessInputStream@2548dfca
} catch (Exception e) {
e.printStackTrace();
}
}
new Thread(new Runnable() {
public void run() {
try {
Process p = new ProcessBuilder("input", "keyevent",Integer.toString(KeyEvent.KEYCODE_HEADSETHOOK)).start();
p.waitFor(); // if I don't do this, I get a java.lang.IllegalThreadStateException
System.out.println("exitValue: " + p.exitValue()); //returned: 0
System.out.println("error: " + p.getErrorStream()); // returned: java.lang.ProcessManager$ProcessInputStream@2548dfca
} catch (Exception e) {
e.printStackTrace();
}
}
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!
Bookmarks