PopupWindow $BadTokenException: Unable to add window — token null is not valid

后端 未结 11 2199

I have the following error when showing a PopupWindow. The errors are triggered by the line:

checkInPopup.showAtLocation((ViewGroup) mapView.getParent(), Gra         


        
11条回答
  •  半阙折子戏
    2020-11-27 05:18

    Following many hours of search and testing i found following solution(by implementing different SO solutions) here it what didn't failed in any case i was getting crash.

         Runnable runnable = new Runnable() {
                @Override
                public void run() {
    
              //displayPopup,progress dialog or what ever action. example
    
                    ProgressDialogBox.setProgressBar(Constants.LOADING,youractivityName.this);
                }};
    

    Where logcat is indicating the crash is happening.. start a runnable .in my case at receiving broadcast.

    runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if(!isFinishing()) {
                        new Handler().postAtTime(runnable,2000);
                    }
                }
            });
    

提交回复
热议问题