I am working on a solution where I am loading a url. I need to get Http Error so that I can reload the url to create a new session.
@Override
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
super.onReceivedHttpError(view, request, errorResponse);
Toast.makeText(getActivity(), "Unexpected error occurred.Reload page again.", Toast.LENGTH_SHORT).show();
if(errorResponse.getStatusCode() == 401){
customWebView.loadUrl(url);
}
}
But the problem with above code is that it work from Marshmallow. Can any one suggest me a solution where I can get error below android version < 23?