Note that there are some explanatory texts on larger screens.

plurals
  1. POBypass modal Android dialogs by clicking buttons twice fast enough?
    primarykey
    data
    text
    <p>Let's say we have two buttons, each with a OnClickListener. Each of listeners show a ProgressDialog and do some background work. (Behind the scene is an AsyncTask, the dialog is opened in onPreExecute. I don't think it matters, just for the record...). Let's say there is some rule saying no more than one background worker may be active at any given time. </p> <p>My assumption was that the Dialog prevents two background workers running at the same time. I thought the modal dialog blocks the UI and it's not possible to click another button after the show() method of the dialog is called. I was wrong.</p> <p>If you click the buttons fast enough, it's possible to trigger both background workers (almost) at the same time. The log shows that it's possible to click two Buttons within a 150 ms time span despite the Dialog:</p> <pre> 04-14 18:34:04.390: DEBUG/greenrobot(1860): Clicked: 2131034112 04-14 18:34:04.470: DEBUG/greenrobot(1860): doInBackground2: 2131034112 04-14 18:34:04.540: DEBUG/greenrobot(1860): Clicked: 2131034113 04-14 18:34:04.570: DEBUG/greenrobot(1860): doInBackground2: 2131034113 </pre> <p>The dialog code looks like this:</p> <pre><code>progressDialog = new ProgressDialog(currentActivity); progressDialog.setMessage(msg); progressDialog.show(); </code></pre> <p>What did I miss? I hope I missed something really stupid, because if not, I cannot think of a nice and solution preventing UI interaction after the click. Synchronizing the background workers is not a solution because the UI and scenario is more complex. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload