Rectangle 27 0

want to redirect webview to other intent when url loading has finished in webview android?


webView.setWebViewClient(new WebViewClient() {
    public void onPageFinished(WebView view, String url) {
         if (url.endsWith("paymentconfirmation/"))
                ((DibsPaymentScreen) getContext())
                        .setCancelDisallowed(false);
            if (callbackUrl.equals(url)
                    && statusCancelled.equals(paymentData.params
                            .get(statusKey))) {
                paymentResultListener.cancelUrlLoaded();
            } else if (callbackUrl.equals(url)
                    && statusAccepted.equals(paymentData.params
                            .get(statusKey))) {
                paymentResultListener.paymentAccepted(paymentData.params);

            } else if (!windowIsLoaded) {
                paymentWindowLoaded();
            }

            if (url.equals("http://nmotion.dk/paymentconfirmation/")) {
                            Intent intent = new Intent(getContext(),
                            RestaurantsListScreen.class);
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    getContext().startActivity(intent);
                   }

            super.onPageFinished(view, url);
    }
});

how would you solve that?

why should not you call "if (url.equals("nmotion.dk/paymentconfirmation/")) { .... } " before "super.onPageFinished(view, url);"

with your code suggestion and ryoghurt code suggestions.

Note
Rectangle 27 0

want to redirect webview to other intent when url loading has finished in webview android?


public void onPageFinished(WebView view, String url) {
   if (url.equals("http://nmotion.dk/paymentconfirmation/")) {

       Intent intent = new Intent(getContext(), RestaurantsListScreen.class);
       intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
       getContext().startActivity(intent);

       return true;

   } else {
            if (url.endsWith("paymentconfirmation/")){
                ((DibsPaymentScreen) getContext()).setCancelDisallowed(false);
            }
            if (callbackUrl.equals(url) && statusCancelled.equals(paymentData.params.get(statusKey))) {
                paymentResultListener.cancelUrlLoaded();

            } else if (callbackUrl.equals(url)

               && statusAccepted.equals(paymentData.params.get(statusKey))) {
                paymentResultListener.paymentAccepted(paymentData.params);

            } else if (!windowIsLoaded) {
                paymentWindowLoaded();

            }

            super.onPageFinished(view, url);

    }
webview.setWebViewClient(new WebViewClient(){
    @Override
    public void onPageFinished(WebView view, String url) {
        // create your intent here
        super.onPageFinished(view, url);
    }
});

please see the code and help me guys

you have to implement the on finish loader in the WebView WebViewCLient

you have to move the intent in the OnPageFinished (check there if (url.equals("nmotion.dk/paymentconfirmation/")) ) because the shouldOverrideUrlLoading prevent the webview to load the url (it's fired before the loading)

Note