하이브리드 앱 웹뷰에서 파일 다운로드를 구현하려고 하는데요
onDownloadStart 함수에 아래 코드와 같이 다운로드를 하는데요
파일이 8~90프로 정도만 다운 되고 중간에 멈춰버리는 증상이 있습니다.
1.2메가는 1.1메가만 받아지고 350kb 파일은 330kb만 받아집니다. 아무리 찾아봐도 이유를 모르겠습니다;;
같은 url로 일반 브라우저 앱에서는 잘 되는데 말이죠 ....
혹시 아시는 분 계신가요 ㅠ
webview_main.setDownloadListener(new DownloadListener()
{
@Override
public void onDownloadStart(final String url, final String userAgent, final String contentDisposition, final String mimeType, long contentLength) {
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setMimeType(mimeType);
String cookies = CookieManager.getInstance().getCookie(url);
request.addRequestHeader("cookie", cookies);
request.addRequestHeader("User-Agent", userAgent);
request.setDescription("Downloading File...");
request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimeType));
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(url, contentDisposition, mimeType));
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
Toast.makeText(getApplicationContext(), "Downloading File", Toast.LENGTH_LONG).show();
}});