Override Cordova Java Class

I need to override a Cordova Class the resists in “node_modules/cordova-android/framework/src/org/apache/cordova/CordovaActivity.java”

But any changes i do are ignored. Do i have to recompile my app to achieve changes?

In what way are they being ignored?

Are the changes not showing up in the App when you run it on a device or in an emulator?

I need to change the “onReceivedError” Method to invoke an Alert when Cell and WiFi is disabled on App startup. Otherwise it shows up the Standard Error Page “Page could not be loaded” in WebView

In my case ( and i hope it is the right one ) it should be this Method ( node_modules/cordova-android/framework/src/org/apache/cordova/CordovaActivity.java)

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);
                    }
                }
            });
        }
    }

Even if i provoke an Error, like writing some some Text into this Method, it doesn’t throw an Error

I found this possible Solutions


BTW:
I’m running it this way:

  1. cordova clean
  2. ionic cordova emulate android -lc --target Android-7 – -d

Do have have any Idea?