小编ABH*_*BHI的帖子

onReceivedHttpError :支持 Android 版本 < 23

我正在研究一个正在加载网址的解决方案。我需要获取 Http 错误,以便我可以重新加载 url 来创建新会话。

@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);
            }
        }
Run Code Online (Sandbox Code Playgroud)

但上述代码的问题在于它是从 Marshmallow 运行的。任何人都可以建议我一种解决方案,让我在 Android 版本 < 23 以下时出现错误吗?

android

5
推荐指数
1
解决办法
4490
查看次数

标签 统计

android ×1