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 8804429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:36:09+00:00 2026-06-14T01:36:09+00:00

I am getting this runtime exception about once every thousand+ sessions on the app,

  • 0

I am getting this runtime exception about once every thousand+ sessions on the app, so it is rare and I have not been able to reproduce it.

java.lang.IllegalArgumentException: View not attached to window manager
        at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:381)
        at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:226)
        at android.view.Window$LocalWindowManager.removeView(Window.java:432)
        at android.app.Dialog.dismissDialog(Dialog.java:278)
        at android.app.Dialog.access$000(Dialog.java:71)
        at android.app.Dialog$1.run(Dialog.java:111)
        at android.os.Handler.handleCallback(Handler.java:587)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        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)

Would anyone know how to reproduce it, or why it happens? Or better yet, how to fix it? 🙂

Thanks!

EDIT:

I added the suggestion made by Raghav to add this:

<activity android:label="@string/app_name" 
        android:configChanges="orientation|keyboardHidden" 
        android:name="ActivityName">

But this has not fixed the crashing and the crashing is still happening.

EDIT:

Here is some typical code I use:

public class ProblemActivity extends BaseListActivity
{
    Dialog dialog;

        ....


@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

    ...

    // After some action
    dialog.show();
}

public class GetSolutionTopicsTask extends AsyncTask<String, Void, String> 
{
    @Override
    protected String doInBackground(String... theParams) 
    {
        String myUrl = theParams[0];
        String problem_id = theParams[1];

        String charset = "UTF-8";           
        String response = null;

        try 
        {               
            String query = String.format("problem_id=%s", 
                     URLEncoder.encode(problem_id, charset));

            final URL url = new URL( myUrl + "?" + query );

            final HttpURLConnection conn = (HttpURLConnection) url.openConnection();

            conn.setDoOutput(true); 
            conn.setRequestMethod("POST");

            conn.setDoOutput(true);
            conn.setUseCaches(false);

            conn.connect();

            final InputStream is = conn.getInputStream();
            final byte[] buffer = new byte[8196];
            int readCount;
            final StringBuilder builder = new StringBuilder();
            while ((readCount = is.read(buffer)) > -1) 
            {
                builder.append(new String(buffer, 0, readCount));
            }

            response = builder.toString();      
        } 
        catch (Exception e) 
        {

        }

        return response;
    }

    @Override
    protected void onPostExecute(String result) 
    {           
        if ( result == null  )
        {
            try 
            {
                dialog.dismiss();
            } catch (Exception e) {
                // nothing
            }

        }
        else
        {
            try 
            {
                    dialog.dismiss();
                } 
            catch (Exception e) 
            {
                // nothing
                }    
         }  // End of else

}        
}        
  • 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-14T01:36:11+00:00Added an answer on June 14, 2026 at 1:36 am

    In some devices and also some cases activity gets finished before dialog successfully dismisses or asynchronous task is running in background , so when you call the dialoge to dismiss it causes

    java.lang.IllegalArgumentException: View not attached to window manager

    as the main ui thread is already dismissed.

    In order to solve this you can track if the activity finished , so make the dialog null in onStop of the activity and then in onPostExecute check the status of the dialog; Code will be like

    @Override
    public void onStop() {
        super.onStop();
        dialog = null;
    }
    

    and in onpostexecute

    if (dialog != null) { 
            dialog.dismiss();
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some of our users are getting this exception sometimes (not for every contact): System.Runtime.InteropServices.COMException
I am Getting a run time Exception while using this code Runtime rt =
With many HQL queries, time and time again I am getting this exception: Antlr.Runtime.NoViableAltException
I am getting this weird RunTime error. The classes compile easy on eclipse but
I am getting this error when I click my submit button Microsoft JScript runtime
Getting this weird LINQ error. title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String Here is the code I have:
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
I have created a backend for my google app that looks like this: backends:
I keep getting this error about my sql database NEW ERROR 07-03 01:52:08.037: ERROR/AndroidRuntime(627):
I'm trying to integrate abs into my app, but I keep getting this error

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.