Note that there are some explanatory texts on larger screens.

plurals
  1. POGettring a reference to a managed ProgressDialog
    primarykey
    data
    text
    <p>In my activity I need a <code>ProgressDialog</code> with a horizontal progress bar to visualise the progress of a background task. To make the activity care for the dialog e.g. in case of screen rotation, I would like to use a managed dialog created in <code>onCreateDialog</code>. The problem is that I need to update the progress bar of the dialog after it has been created and therefor I need a reference to the managed progress dialog: Does anyone know how to retrieve a reference to a dialog created by <code>onCreateDialog</code>?</p> <p>At the moment I am storing a reference to the dialog created in <code>onCreateDialog</code>, but that my fail with a <code>InvalidArgumentException</code> in the <code>onFinished()</code> method after the screen has been rotated (and the activity has been recreated):</p> <pre><code>public final class MyActivity extends Activity { private static final int DIALOG_PROGRESS = 0; private ProgressDialog progressDialog = null; // [...] @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_PROGRESS: progressDialog = createProgressDialog(); return progressDialog; default: return super.onCreateDialog(id); } } // [...] public void updateProgress(int progress) { progressDialog.setProgress(0); } public void onFinished() { progressDialog.dismiss(); } // [...] } </code></pre> <p>I would have expected something like a <code>getDialog(int)</code> method in the <code>Activity</code> class to get a reference to a managed dialog, but this doesn't seem to exist. Any ideas?</p>
    singulars
    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