2

I am experiencing funny behavior of monkey. When app shows AlertDialog with two buttons, my onClick handler sometimes called twice. This does not happen when I press the button manually, only when using monkey.

Here is my activity code:

@Override
public void onResume() {
    super.onResume();

    Log.d(TAG, "onResume");

    AlertDialog.Builder builder = new AlertDialog.Builder(this)
    .setPositiveButton("yes", this)
    .setNegativeButton("no", this);

    AlertDialog alert = builder.create();
    alert.show();
}

@Override
public void onClick(DialogInterface pDialog, int pWhich) {
    Log.d(TAG, "onClick " + pWhich);

    pDialog.dismiss();
}

This is how I call monkey:

adb shell monkey -p com.mycompany.helloapp -v 500

And here is logcat output (irrelevant lines are skipped):

09-26 12:27:04.867 D/ClickTest(27989): onResume
09-26 12:27:07.557 D/ClickTest(27989): onClick -1
09-26 12:27:07.557 D/ClickTest(27989): onClick -1

Am I doing anything wrong or this is some sort of bug in android UI event handler thet reproduces under high event load?

-Lev

gbudan
  • 889
  • 7
  • 17
lstipakov
  • 3,138
  • 5
  • 31
  • 46
  • Interesting! I'm not familiar with this issue, but I'll stay around to get some info on it :) – Michell Bak Sep 26 '11 at 09:51
  • Problem seems went away when I've added throttle 50ms. I tested 20 times and got only single onClick call per test. With throttle 25ms I got duplicate call several times. – lstipakov Sep 26 '11 at 10:27
  • http://code.google.com/p/android/issues/detail?id=20073&q=onclick&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars – lstipakov Sep 28 '11 at 14:02
  • You are not using MonkeyRunner here. It is Monkey which is different than MonkeyRunner. Please see: [Monkey](http://developer.android.com/tools/help/monkey.html) vs. [MonkeyRunner](http://developer.android.com/tools/help/monkeyrunner_concepts.html) – gbudan May 19 '14 at 17:26

0 Answers0