小编eug*_*ene的帖子

Android WebClient,通过WebResourceResponse返回图像资源 - 不显示图像

我有一个简单的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.

有什么建议可以作为替代方案吗?

谢谢!

android webview webviewclient

6
推荐指数
1
解决办法
3821
查看次数

标签 统计

android ×1

webview ×1

webviewclient ×1