【Android】android.view.WindowManager$BadTokenException exception fix

background

bold style
The above problem emerged: Official Documents

solve:

My problem is that the activity is destroyed, and the result is a crash caused by the Dialog popping up, which is handled asynchronously.

 if(isFinishing()){
    
    
                    // 在异步情况下,如果activity销毁后再弹dialog 会导致异常,故如果正在销毁就不要弹出dialog
                    return;
                }

reference

Guess you like

Origin blog.csdn.net/weixin_44002043/article/details/133862689