当Activity已经Finish了,还弹对话框的话,就会报这个错
· 1Caused by: android.view.WindowManager$BadTokenException:Unable to add window -- token android.os.BinderProxy@42b22048 is not valid; isyour activity running?
· 2 atandroid.view.ViewRootImpl.setView(ViewRootImpl.java:541)
· 3 atandroid.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259)
· 4 atandroid.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
· 5 at android.app.Dialog.show(Dialog.java:286)
· 6 atcom.mama100.android.member.wxapi.WXPayHelper.showWXPayFailedDialog(WXPayHelper.java:88)
· 7 atcom.mama100.android.member.activities.mothershop.SubmitOrderActivity$3.onCheckStatusResponse(SubmitOrderActivity.java:941)
· 8 atcom.mama100.android.member.wxapi.CheckWXPayStatus$TaskCheckWXPayStatus.handleResponse(CheckWXPayStatus.java:55)
· 9 atcom.mama100.android.member.activities.AsyncReqTask.onPostExecute(AsyncReqTask.java:50)
· 10 at com.mama100.android.member.activities.AsyncReqTask.onPostExecute(AsyncReqTask.java:1)
解决办法 :
在dialog初始化前先加判断
if (mContext.isFinishing()) {
return;
}
转载于:https://blog.51cto.com/mama100tech/1659679