在我的Android应用中,我在onPostResume()
的{{1}}中显示了一个进度对话框。
MainActivity
我从同一个用户那里获得了一些具有以下堆栈跟踪信息的崩溃报告。
@Override
protected void onPostResume() {
super.onPostResume();
if (!isDestroyed()) {
ProgressDialog progressDialog = ProgressDialog.show(this, getString(R.string.loading), getString(R.string.please_wait), true);
// Do stuff
}
}
我在本地进行了测试,并且没有崩溃。我无法在任何设备上重新创建它。
这可能是什么原因?为什么Caused by android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@ffbb5f4 is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:567)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:310)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
at android.app.Dialog.show(Dialog.java:319)
at android.app.ProgressDialog.show(ProgressDialog.java:116)
at android.app.ProgressDialog.show(ProgressDialog.java:99)
at com.my.app.MainActivity.onPostResume(MainActivity.java:333)
at android.app.Activity.performResume(Activity.java:6366)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3092)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:746)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
会发生,即使BadTokenException
为假?