Send authorization header with every request in webview using okhttp in android

我的梦境 提交于 2019-12-04 08:03:07

Finally this will rectify the html rendering issue (Pardon me, I didn't notice this earlier).

change content-type in

return new WebResourceResponse(response.header("content-type", response.body().contentType().type()), // You can set something other as default content-type
                        response.header("content-encoding", "utf-8"),  // Again, you can set another encoding as default
                        response.body().byteStream());

to text/html , so the new code is

return new WebResourceResponse(response.header("text/html", response.body().contentType().type()), // You can set something other as default content-type
                    response.header("content-encoding", "utf-8"),  // Again, you can set another encoding as default
                    response.body().byteStream());

If my solution needs any modifications, feel free to edit. Always accept better solutions. Happy coding...And Thanks everyone #SO ready to help.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!