小编Ger*_*nan的帖子

尝试在JSF中下载动态文件时,未触发Android WebView downloadlistener

当我点击JSF页面中的下载按钮时,我试图在Android的WebView上触发DownloadListener事件,这些下载链接是动态生成的.它在谷歌浏览器中运行得很好,但它在WebView上无效,我无法理解.

我只需要在单击按钮时触发此事件.你能帮助我吗?

下载:

public void download(Download obj) throws IOException {
    byte[] download = .... // obj byte[] loaded here
    FacesContext context = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse) context
            .getExternalContext().getResponse();
    response.reset();
    response.setBufferSize(DEFAULT_BUFFER_SIZE);
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Length", String.valueOf(download.length));
    response.setHeader("Content-Disposition", "attachment;filename=\"download\"");
    BufferedInputStream input = null;
    BufferedOutputStream output = null;
    try {
        input = new BufferedInputStream(new ByteArrayInputStream(download),
                DEFAULT_BUFFER_SIZE);
        output = new BufferedOutputStream(response.getOutputStream(),
                DEFAULT_BUFFER_SIZE);
        byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
        int length;
        while ((length = input.read(buffer)) > 0) {
            output.write(buffer, 0, length);
        }
    } finally {
        input.close();
        output.close(); …
Run Code Online (Sandbox Code Playgroud)

jsf android download webview

5
推荐指数
0
解决办法
522
查看次数

标签 统计

android ×1

download ×1

jsf ×1

webview ×1