1. Set the success url to 'http://localhost:8989/response/success' -> actually this can be anything as long as it is handled in the shouldOverrideUrlLoading function explained below

2. Set the cancel url to 'http://localhost:8989/response/cancel' -> actually this can be anything as long as it is handled in the shouldOverrideUrlLoading function explained below

3. Override the shouldOverrideUrlLoading function of the WebViewClient:


        @Override

        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            // The success url and cancel url can be anything since it will be handled by our code, not the web view

            if (url.equals("http://localhost:8989/response/success")) {

                view.loadUrl("file:///android_asset/www/index.html");

                return true; // This is important to indicate that we have handled the url, if we return false that means we will let the url to be handled by webview which will throw the error

            } else if (url.equals("http://localhost:8989/response/cancel")) {

                view.loadUrl("file:///android_asset/www/order_detail.html");

                return true; // This is important to indicate that we have handled the url, if we return false that means we will let the url to be handled by webview which will throw the error

            }

            return super.shouldOverrideUrlLoading(view, url);

        }