Java Code Examples for android.webkit.WebViewClient#ERROR_HOST_LOOKUP

The following examples show how to use android.webkit.WebViewClient#ERROR_HOST_LOOKUP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CordovaActivity.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (errorUrl.startsWith("file://") || internalWhitelist.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {

        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                // Stop "app loading" spinner if showing
                me.spinnerStop();
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 2
Source File: CordovaActivity.java    From phonegapbootcampsite with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = me.getStringProperty("errorUrl", null);
    if ((errorUrl != null) && (errorUrl.startsWith("file://") || Config.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {

        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                // Stop "app loading" spinner if showing
                me.spinnerStop();
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 3
Source File: CordovaActivity.java    From reader with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (errorUrl.startsWith("file://") || internalWhitelist.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {

        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                // Stop "app loading" spinner if showing
                me.spinnerStop();
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 4
Source File: CordovaActivity.java    From reader with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (errorUrl.startsWith("file://") || internalWhitelist.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {

        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                // Stop "app loading" spinner if showing
                me.spinnerStop();
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 5
Source File: CordovaActivity.java    From lona with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode   The error code corresponding to an ERROR_* value.
 * @param description A String describing the error.
 * @param failingUrl  The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.getView().setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 6
Source File: CordovaActivity.java    From CordovaYoutubeVideoPlayer with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = me.getStringProperty("errorUrl", null);
    if ((errorUrl != null) && (errorUrl.startsWith("file://") || Config.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {

        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                // Stop "app loading" spinner if showing
                me.spinnerStop();
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 7
Source File: CordovaActivity.java    From chappiecast with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.getView().setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 8
Source File: CordovaActivity.java    From bluemix-parking-meter with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (errorUrl.startsWith("file://") || internalWhitelist.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {

        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 9
Source File: CordovaActivity.java    From cordova-plugin-intent with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.getView().setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 10
Source File: CordovaActivity.java    From a2cardboard with Apache License 2.0 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.getView().setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 11
Source File: CordovaActivity.java    From cordova-android-chromeview with Apache License 2.0 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = me.getStringProperty("errorUrl", null);
    if ((errorUrl != null) && (errorUrl.startsWith("file://") || Config.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {

        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                // Stop "app loading" spinner if showing
                me.spinnerStop();
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 12
Source File: CordovaActivity.java    From L.TileLayer.Cordova with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (errorUrl.startsWith("file://") || internalWhitelist.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {

        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 13
Source File: CordovaActivity.java    From cordova-plugin-app-update-demo with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode   The error code corresponding to an ERROR_* value.
 * @param description A String describing the error.
 * @param failingUrl  The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.getView().setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 14
Source File: CordovaActivity.java    From app-icon with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode   The error code corresponding to an ERROR_* value.
 * @param description A String describing the error.
 * @param failingUrl  The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.getView().setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 15
Source File: BaseWebActivity.java    From QRScanner with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onWebViewReceivedError(WebView view, int errorCode, CharSequence description, String failingUrl) {
    Log.i("0000", "errorCode:   " + errorCode);
    switch (errorCode) {
        case WebViewClient.ERROR_CONNECT:
        case WebViewClient.ERROR_TIMEOUT:
        case WebViewClient.ERROR_HOST_LOOKUP:
        case WebViewClient.ERROR_BAD_URL:
            showErrorHint(failingUrl);
            break;
    }
}
 
Example 16
Source File: CordovaActivity.java    From wildfly-samples with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = me.getStringProperty("errorUrl", null);
    if ((errorUrl != null) && (errorUrl.startsWith("file://") || Config.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {

        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                // Stop "app loading" spinner if showing
                me.spinnerStop();
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 17
Source File: CordovaActivity.java    From keemob with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode   The error code corresponding to an ERROR_* value.
 * @param description A String describing the error.
 * @param failingUrl  The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.getView().setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 18
Source File: CordovaActivity.java    From phonegap-plugin-loading-spinner with Apache License 2.0 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = me.getStringProperty("errorUrl", null);
    if ((errorUrl != null) && (errorUrl.startsWith("file://") || Config.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {

        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                // Stop "app loading" spinner if showing
                me.spinnerStop();
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example 19
Source File: BaseWebActivity.java    From qrcode_android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onWebViewReceivedError(WebView view, int errorCode, CharSequence description, String failingUrl) {
    Log.i("0000", "errorCode:   " + errorCode);
    switch (errorCode) {
        case WebViewClient.ERROR_CONNECT:
        case WebViewClient.ERROR_TIMEOUT:
        case WebViewClient.ERROR_HOST_LOOKUP:
        case WebViewClient.ERROR_BAD_URL:
            showErrorHint(failingUrl);
            break;
    }
}
 
Example 20
Source File: CordovaActivity.java    From xmall with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode   The error code corresponding to an ERROR_* value.
 * @param description A String describing the error.
 * @param failingUrl  The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.getView().setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}