Note that there are some explanatory texts on larger screens.

plurals
  1. POBlock onclick events when activity is paused
    primarykey
    data
    text
    <p>I am able to get onClick event running on a paused activity. I thought it should not happen, and I am hoping for some clues on how to fix this.</p> <p>In my Activity (extends RoboFragmentActivity) I have a simple TextView entry for date. OnClick event of this TextView is showing a DatePickerFragment:</p> <pre><code>public void onDateRowBoxClick(View view) { new DatePickerFragment().show(getSupportFragmentManager(), "datePicker"); } </code></pre> <p>I also have an AsyncTask, which in its OnPostExecute event starts another activity. The AsyncTask shows a progress dialog (the operation takes several seconds), which hides the date view.</p> <p>During the AsyncTask.doInBackground operation I am clicking the area on the progress dialog, which hides the date view. After the async task completes, the progress dialog is dismissed and another activity should be starting.</p> <p>Instead, I am getting the onClick event on the date view. It throws up with IllegalStateException, because the activity is already paused and the fragments cannot deal with it (I get IllegalStateException: Could not execute method of the activity, IllegalStateException: Can not perform this action after onSaveInstanceState; at onDateRowBoxClick). However I think the event should not be passed to a paused activity. My questions are: am I right and how to fix this?</p> <p>For now I have this workaround, but it's rather silly:</p> <pre><code>boolean paused = true; @Override protected void onResume() { super.onResume(); paused = false; } @Override protected void onPause() { super.onPause(); paused = true; } public void onDateRowBoxClick(View view) { if (!paused) new DatePickerFragment().show(getSupportFragmentManager(), "datePicker"); } </code></pre> <p>BTW, at first I thought it is relevant to <a href="http://code.google.com/p/android/issues/detail?id=19917" rel="nofollow">http://code.google.com/p/android/issues/detail?id=19917</a>, but the workaround do not work for me.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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