我们的应用程序在进度条上调用dismiss方法时崩溃了。我无法在我的设备中重现此崩溃,但这种情况发生在生产中。
public class SomeActivity extends BaseActivity {
public SomeActivity() {
super(true);
}
private WebView webView;
private boolean hasRedirected = false;
ProgressDialog loadingDialog;
public void onCreate(Bundle savedInstanceState) {
...
...
loadingDialog = new ProgressDialog(this);
loadingDialog.setCancelable(true);
loadingDialog.setMessage("Loading...");
loadingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
loadingDialog.setIndeterminate(true);
Intent intent = getIntent();
String url = intent.getStringExtra(SomeActivity.urlToLoad);
webView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setSupportZoom(true);
webView.loadUrl(url);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished (WebView view, String url) {
if (!url.equals("about:blank"))
loadingDialog.dismiss();
}
@Override
public void onPageStarted (WebView view, String url, Bitmap favicon) {
if (!url.equals("about:blank"))
loadingDialog.show();
}
...
...
});
}
...
...
}
堆栈跟踪:
java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView{1c03950b V.E..... R.....ID 0,0-1336,0} not attached to window manager
at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:412)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:338)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:118)
at android.app.Dialog.dismissDialog(Dialog.java:509)
at android.app.Dialog.dismiss(Dialog.java:492)
at com.xyz.activities.notification.SomeActivity$1.onPageFinished(SomeActivity.java:85)
at com.android.webview.chromium.WebViewContentsClientAdapter.onPageFinished(WebViewContentsClientAdapter.java:513)
at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:188)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6895)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)