关于android.view.WindowManager$BadTokenException问题出现以及解决的一些记录

时间:2023-03-09 21:20:58
关于android.view.WindowManager$BadTokenException问题出现以及解决的一些记录

1.出现

在app showdialog()时偶尔会出现,根据*.com的描述,貌似是show的时候用作context的activity以及destroy了,,,一些异步操作会导致这个问题。

贴出一些解决的issue

http://*.com/questions/9529504/unable-to-add-window-token-android-os-binderproxy-is-not-valid-is-your-activ

http://*.com/questions/7811993/error-binderproxy45d459c0-is-not-valid-is-your-activity-running

http://*.com/questions/5934050/check-whether-activity-is-active/8963867#8963867

目前先试试if(!((Activity) context).isFinishing())
{
    //show dialog
}