2017-08-25 133 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

我的回答不對您有幫助嗎? –