我有一个简单的WebViewClient用于我的WebView并且覆盖了shouldInterceptRequest :(不是实际的代码)
public class WebViewClientBook extends WebViewClient
{
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url)
{
File file = new File("pathToTheFile.jpeg");
FileInputStream inputStream = new FileInputStream(file);
return new WebResourceResponse("image/jpeg", "UTF-8", inputStream);
}
}
Run Code Online (Sandbox Code Playgroud)
由于某种原因,WebClient无法显示图像...我相信它可能与不正确的编码有关:UTF-8.
有什么建议可以作为替代方案吗?
谢谢!