diff --git a/fastlane/metadata/android/en-US/changelogs/401.txt b/fastlane/metadata/android/en-US/changelogs/401.txt index 35bc0e1..423c52e 100644 --- a/fastlane/metadata/android/en-US/changelogs/401.txt +++ b/fastlane/metadata/android/en-US/changelogs/401.txt @@ -5,3 +5,4 @@ Improved Fixed • Catch exceptions when launching PDF viewer. +• If receive 404 error when loading show settings page. diff --git a/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java b/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java index 4e159bb..1d5d8ba 100644 --- a/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java +++ b/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java @@ -46,6 +46,7 @@ import android.webkit.WebChromeClient; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; +import android.webkit.WebResourceResponse; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -592,6 +593,18 @@ public void onPageStarted(WebView view, String u, Bitmap favicon) { super.onPageStarted(view, u, favicon); } + @Override + public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { + Log.d(TAG, "onReceivedHttpError url:" + request.getUrl() + ", mf:" + request.isForMainFrame() + ", sc:" + errorResponse.getStatusCode()); + if (request.isForMainFrame() && 404== errorResponse.getStatusCode() && request.getUrl().toString().equals(getConfiguredUrl())) { + pageError = true; + //discoverServer(false); + pageLoadHandler.removeCallbacks(pageLoadTimeout); + navigateToSettingsActivity(); + } + super.onReceivedHttpError(view, request, errorResponse); + } + @Override public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {