X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.kt;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.kt;h=75aa38beaf7139c878410fd0a05f80a4b09fe3e6;hp=b56a02f0d0adc08e0da393bcbc448303f5191768;hb=74e8a8368db991ee511c216a298c4ff5201f41de;hpb=e6befb69eb16e4c633623df508bfb9de370e204f diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt index b56a02f0..75aa38be 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -5455,8 +5455,14 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Instantiate an HTTP authentication dialog. val httpAuthenticationDialogFragment = HttpAuthenticationDialog.displayDialog(host, realm, nestedScrollWebView.webViewFragmentId) - // Show the HTTP authentication dialog. - httpAuthenticationDialogFragment.show(supportFragmentManager, getString(R.string.http_authentication)) + // Try to show the dialog. WebView can receive an HTTP authentication request even after the app has been paused. Attempting to display a dialog in that state leads to a crash. + try { + // Show the HTTP authentication dialog. + httpAuthenticationDialogFragment.show(supportFragmentManager, getString(R.string.http_authentication)) + } catch (exception: Exception) { // The dialog could not be shown. + // Add the dialog to the pending dialog array list. It will be displayed in `onStart()`. + pendingDialogsArrayList.add(PendingDialogDataClass(httpAuthenticationDialogFragment, getString(R.string.http_authentication))) + } } override fun onPageStarted(webView: WebView, url: String, favicon: Bitmap?) { @@ -5694,7 +5700,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Instantiate an SSL certificate error alert dialog. val sslCertificateErrorDialogFragment = SslCertificateErrorDialog.displayDialog(error, nestedScrollWebView.webViewFragmentId) - // Try to show the dialog. The SSL error handler continues to function even when the WebView is paused. Attempting to display a dialog in that state leads to a crash. + // Try to show the dialog. The SSL error handler continues to function even when the app has been stopped. Attempting to display a dialog in that state leads to a crash. try { // Show the SSL certificate error dialog. sslCertificateErrorDialogFragment.show(supportFragmentManager, getString(R.string.ssl_certificate_error))