2017-08-25 189 views
0

我想让用户通过WebView登录我们的应用程序,但是当试图登录时,我收到一个错误,说ERR_TOO_MANY_REDIRECTS。登录协议由5个重定向组成,但我们无法控制它。Android WebView ERR_TOO_MANY_REDIRECTS

它在Web浏览器中工作,但Anroid WebView开始认为我们在重定向循环并取消了整个事情。直到API 8有一个函数onTooManyRedirects(WebView view, Message cancelMsg, Message continueMsg),它允许你继续,但现在不再使用。

我能做些什么来解决这个问题?

回答

0

创建一个WebViewClient,并重写shouldOverrideUrlLoading方法。

webview.setWebViewClient(new WebViewClient() { 
    public boolean shouldOverrideUrlLoading(WebView view, String url){ 
     // do your handling codes here, which url is the requested url 
     // probably you need to open that url rather than redirect: 
     view.loadUrl(url); 
     return false; // then it is not handled by default action 
    } 
}); 
+0

我的回答不对您有帮助吗? –