0

I have just made an android application as System app to start monkey command for Calculator package. My app has a button and it will start monkey once clicked.

public void onClick(View v) {
  try {
        Runtime.getRuntime().exec("monkey -p com.google.android.calculator  --throttle 200 -v 10000");
      } catch (IOException e) {
       // to do something
      }
}

==> it worked fine with touches = 1000 but if I increase to 10000, monkey runs for about 1 minutes then freeze screen and I can not do anythings. ==> I trying use Adb shell same monkey command and even though increase touches to 50000, it still work fine. I don't know why my device freeze screen, and what is difference between adb shell monkey and using runtime.exec.

Someone can help me? Thanks in advance^

Iain Duncan
  • 3,139
  • 2
  • 17
  • 28

1 Answers1

0

I found it ! the buffer can not be released.

Process process;
String rd;
process = Runtime.getRuntime().exec("monkey -p com.google.android.calculator  -- 
throttle 200 -v 10000");

BufferedReader reader = new BufferedReader(new 
InputStreamReader(process.getInputStream()));
while((rd = reader.readLine()) != null){
Log.d(TAG,"ip: " + rd);
}
process.waitFor();
reader.close();

=> now, I can try to 50000 touches.