Search code examples
androidwebviewandroid-webviewhttp-redirectwebviewclient

Return back host application after submiting form data from WebView


I am developing a android application, Within the application I am trying to Load a URL using WEBVIEW. Afer i submit the data in the opened webpage, it gets redirected to some other URL. My requirement is to get the complete Redirected URL within my android application.

I didnt see any events/ API methods which can be used to notify URL Redirect.

Are there any way to listen for URL redirects within my application and then retrieve the URL.


Solution

  • you can identify the redirection using webClient just set webclient on your webview

    like below

        myWebView.setWebViewClient(new WebViewClient()       
                {
                     @Override
                    public boolean shouldOverrideUrlLoading(WebView view, String url) 
                    {
    
                        //do your stuff here 
                        if(url.equalsIgnoreCase("your redirect url "))
                        {
                          return false;
                        }
                        return true;
                    }
                });