【问题标题】: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;
}
});