Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8569695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:23:47+00:00 2026-06-11T18:23:47+00:00

My Problem is similar to this one: Error on dismissing ProgressDialog in AsyncTask I

  • 0

My Problem is similar to this one:

Error on dismissing ProgressDialog in AsyncTask

I have an AsyncTask that creates a dialog in onPreExecute like this:

dialog = ProgressDialog.show(activity, "login", "logging in, one moment please");

And dismisses the dialog in onPostExecute like this:

if (dialog != null && dialog.isShowing()) {
    dialog.dismiss();
}

Still, i get error reports from users on the line where i do diolog.dismiss() with the message:
java.lang.IllegalArgumentException: View not attached to window manager

The most common root-cause is – or so i’ve read – when a user switches orientation (from portrait to landscape or vice versa).
My app however is forced to portrait mode, so this can not be the cause. (i’ve double checked this to make sure it really is not possible)

The reporter of the before mentioned post solved it in the end (and i’ve read this solution elsewhere too) by creating an inner class for the AsyncTask in the activity class and working with onCreateDialog from the activity class and calling showDialog from the AsyncTask. (read his post if you don’t understand this)
I’ve begun trying to implement that, but it seems that showDialog is deprected: so this is not a solution for me.

The last solution i’ve found is by simply catching the Exception. I had thought of that myself too, but only as a last resort. I prefer to understand what really goes wrong and anticipate on that instead of simply catching the exception and not knowing what is going on.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:23:48+00:00Added an answer on June 11, 2026 at 6:23 pm

    If what Chad is saying is correct – that some devices might start in landscape for a fraction of a second – then i think this is the most likely cause for getting the error-reports. While the solution of Rajendra might be able to prevent that, i’ve decided it really does feel like applying a band-aid as others have pointed out, since screen-rotation is not the only source of the real problem.

    After some more searching, i’ve found two solutions:

    1. Implementing the AsyncTask as part of a class which inherits from Application class, which is explained here: Handle screen orientation changes when there are AsyncTasks running
    2. Implement onRetainNonConfigurationInstance() / setRetainInstance(). An example of the first is given here: http://twigstechtips.blogspot.com/2011/11/for-my-app-moustachify-everything-i-was.html – however, the method itself is deprecated, so it would be better to use setRetainInstance in a similar fashion.

    And just for completeness, there’s also the Droid-Fu for Android library, which claims to be able to solve this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Similar to this question: link However I have already mastered that. My problem is
My current problem is very similar to this one . I have a downloadFile(URL)
I have an error very similar to the one addressed in this question .
First off, my problem is quite similar to this one . I would like
I have a problem similar to this one below: Python pip broken after OS
My problem is extremely similar to the one described in this SO question ,
I have checked this similar question, but the suggestions did not solve my problem:
I have a cross-tab report which similar to this Problem is when there are
I notice this thread: Fastish Python/Jython IPC , and I have a similar problem,
I've a similar error to this one , but unfortunately not the same simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.