我得到了錯誤代碼,如果網頁中的任何錯誤通過setWebViewClient的onReceivedHttpError方法,但是當沒有錯誤任何頁面加載成功或服務器回調我代碼如403然後如何檢查狀態代碼200或403.Android:如何在Webview中獲取狀態碼200 OK?
1
A
回答
0
您可以在網頁視圖中使用
webView.setWebViewClient(new WebViewClient() {
@SuppressWarnings("deprecation")
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
// Handle the error
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
@Override
public void onReceivedSslError(final WebView view, final SslErrorHandler handler, final SslError error) {
// TODO Auto-generated method stub
super.onReceivedSslError(view, handler, error);
// handle your SSL related error here
// handler.proceed();
}
});
+0
thx,但這是請求onError ...我想要的正常狀態代碼,如200. –
+0
是在onReceivedError方法中,您也獲得了errorCode。使用它 –
+0
@ShineLee你明白了我的觀點? –
相關問題
- 1. 」狀態代碼:200 OK(來自ServiceWorker)?
- 2. 當HTTP狀態不是200 OK時ASP.NET獲取Web響應
- 3. 如何從scrapy-splash獲取200以外的狀態代碼
- 4. HTTP狀態碼webview android,WebViewClient
- 5. http狀態碼200
- 6. 狀態:200狀態文本:OK的readyState:4
- 7. 在web api中獲取200個空數據的狀態代碼
- 8. 如何獲得「200 OK」的HttpWebResponse?
- 9. nginx狀態碼200和304
- 10. HTTP狀態碼200 vs 202
- 11. 如何獲取Angularjs中的狀態碼?
- 12. Android:如何獲取HttpClient請求的狀態碼
- 13. 如何以編程方式返回200 ok狀態到PHP中的ajax請求?
- 14. HTTP/1.1 200 OK
- 15. 我不明白的狀態碼 - 302/200
- 16. 儘管200 OK狀態,爲什麼AJAX JSON響應失敗?
- 17. Android Volley在200狀態代碼上拋出錯誤
- 18. Windows Phone - 如何獲取HTTP狀態碼?
- 19. 得到錯誤的例外:狀態響應:200 OK的URL:未捕獲和
- 20. 在jquery中獲取http狀態代碼
- 21. 獲取HTTP狀態200,當我應該獲得狀態304使用PHP curl
- 22. Twisted giving twisted.web.client.PartialDownloadError:200 OK
- 23. HTTP POST響應代碼200 OK
- 24. 如何獲取/詢問android的httpRequest狀態碼?
- 25. Android Python獲取GPS狀態
- 26. 如何使鹽層等待200 OK?
- 27. 獲取HTTP狀態代碼
- 28. Android:WebView onReceivedHttpError不返回狀態碼!= 200
- 29. 在返回HTTP 200後執行函數在燒瓶中OK OK
- 30. 如何在android中獲取加載mapview的進度狀態?
看到這個http://stackoverflow.com/q/11889020/6482350。據我所知,在Android M之前的設備中沒有好的方法。 – DysaniazzZ