【问题标题】:Return back host application after submiting form data from WebView从 WebView 提交表单数据后返回宿主应用程序
【发布时间】:2016-02-25 06:42:32
【问题描述】:

我正在开发一个 android 应用程序,在我的应用程序中 尝试使用 WEBVIEW 加载 URL。在我提交数据后 打开网页,它会被重定向到其他 URL。我的要求 是在我的 android 应用程序中获取完整的重定向 URL。

我没有看到任何可用于通知 URL 的事件/API 方法 重定向。

有什么方法可以在我的应用程序中监听 URL 重定向 然后检索 URL。

【问题讨论】:

    标签: android webview android-webview url-redirection webviewclient


    【解决方案1】:

    您可以使用 webClient 识别重定向,只需在您的 webview 上设置 webclient

    如下图

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

    【讨论】:

    • 在你回答任何正确答案之前我已经解决了同样的问题
    猜你喜欢
    • 1970-01-01
    • 2021-12-08
    • 2018-06-05
    • 2015-01-03
    • 1970-01-01
    • 2012-01-30
    • 2021-04-20
    • 2015-09-21
    • 1970-01-01
    相关资源
    最近更新 更多