- // Show the pinned mismatch alert dialog.
- pinnedMismatchDialogFragment.show(fragmentManager, "Pinned Mismatch");
+ // Try to show the dialog. Sometimes the window is not active.
+ try {
+ // Show the pinned mismatch alert dialog.
+ pinnedMismatchDialogFragment.show(fragmentManager, activity.getString(R.string.pinned_mismatch));
+ } catch (Exception exception) {
+ // Add the dialog to the pending dialog array list. It will be displayed in `onStart()`.
+ MainWebViewActivity.pendingDialogsArrayList.add(new PendingDialog(pinnedMismatchDialogFragment, activity.getString(R.string.pinned_mismatch)));
+ }