android View not attached to window manager

后端 未结 13 2381
臣服心动
臣服心动 2020-11-27 10:29

I am having some of the following exceptions:

java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerImpl.findV         


        
13条回答
  •  不知归路
    2020-11-27 11:03

    If you have an Activity object hanging around, you can use the isDestroyed() method:

    Activity activity;
    
    // ...
    
    if (!activity.isDestroyed()) {
        // ...
    }
    

    This is nice if you have a non-anonymous AsyncTask subclass that you use in various places.

提交回复
热议问题