Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: dialog and AsyncTask - why am I getting an IllegalArgumentException?
    primarykey
    data
    text
    <p>I've got an Activity like this:</p> <pre><code>public class StudentActivity extends Activity { static final int DIALOG_PROGRESS = 0; public void btnSyncStudentsClick(View view) { syncStudents(); } @Override protected Dialog onCreateDialog(int id) { Dialog d = null; switch (id) { case DIALOG_PROGRESS: ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getText(R.string.txt_refreshing_students)); d = dialog; break; return d; } private class RefreshStudentTask extends AsyncTask&lt;Void, Integer, AccountRefreshResult&gt; { @Override protected void onPreExecute() { showDialog(DIALOG_PROGRESS); } @Override protected AccountRefreshResult doInBackground(Void... params) { //some network requests } @Override protected void onPostExecute(AccountRefreshResult result) { dismissDialog(DIALOG_PROGRESS); //this throws an exception //some other stuff } } } </code></pre> <p>Since the dialog is shown in onPreExecute() and dismissed in onPostExecute(), I don't know why some of the users get an exception:</p> <pre><code>Uncaught exception handled :/ , thread: Thread[main,5,main] java.lang.IllegalArgumentException: no dialog with id 0 was ever shown via Activity#showDialog at android.app.Activity.missingDialog(Activity.java:2606) at android.app.Activity.dismissDialog(Activity.java:2591) at pl.mobireg.eparent.activities.StudentActivity$RefreshStudentTask.onPostExecute(StudentActivity.java:390) at pl.mobireg.eparent.activities.StudentActivity$RefreshStudentTask.onPostExecute(StudentActivity.java:364) at android.os.AsyncTask.finish(AsyncTask.java:417) at android.os.AsyncTask.access$300(AsyncTask.java:127) at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3691) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>I cannot replicate this issue on my side, so it is very hard to debug.</p> <p>EDIT: Activity should only run in portrait mode:</p> <pre><code>android:screenOrientation="portrait" </code></pre>
    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.
 

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