文件正在保存,但无法在Android中加载

时间:2016-07-02 18:28:29

标签: android android-file android-download-manager

我正从下载管理器下载html文件。该文件正在下载,但无法加载到webview中。

我想html存在一些问题。

下载代码

PATH

文件加载代码

public void myDownload(String myURL, String title, String year, String branch, String section) {

  DownloadManager.Request request = new DownloadManager.Request(Uri.parse(myURL));
  request.setTitle("File Download");
  request.setDescription("Downloading....");

  //request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
  request.allowScanningByMediaScanner();
  request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
  String nameOfFile = URLUtil.guessFileName(myURL, null, MimeTypeMap.getFileExtensionFromUrl(myURL));  

  request.setDestinationInExternalPublicDir(Environment.getExternalStorageDirectory().getPath() + "/KiiTTimeTableData/" + year + "/" + branch + "/" + section + "/", nameOfFile);
  //request.setDestinationInExternalPublicDir("/sdcard/KiiTTimeTableData/" + year + "/" + branch + "/" + section + "/", nameOfFile);
  DownloadManager manager = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);
  manager.enqueue(request);
}

0 个答案:

没有答案