Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get HTTP Status Code in Android WebView

I'm developing an Android app that loads a website in a WebView, but sometimes the website returns HTTP code 500.

My question is: is there any way to get the HTTP status code from a WebView with a listener or with another class??

I tried to implement an WebViewClient, but I couldn't get the HTTP status code which WebView received.

like image 788
Victor Escobar Avatar asked Aug 09 '12 17:08

Victor Escobar


1 Answers

It's not possible (as of the time i'm writing this). The docs for onReceiveError() are ambiguous at best, but it you look at this issue,

http://code.google.com/p/android/issues/detail?id=968

It's clear that HTTP status codes won't be reported through that mechanism. How it's possible that the developers wrote WebView with no way to retrieve the HTTP status code really blows my mind.

like image 69
Jeffrey Blattman Avatar answered Oct 03 '22 01:10

Jeffrey Blattman