PDA

View Full Version : Answer Android Calls



dspelt
24th February 2017, 18:02
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)).s tart();
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@2548df ca
} catch (Exception e) {
e.printStackTrace();
}
}



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!