0
我有一個在圖像和服務器上的文字的HTML文件。我想要將該HTML文件與圖像一起下載。我有用於下載html文件的代碼。但是,我怎樣才能與HTML文件一起下載圖像?如何在Android中保存完整的網頁或HTML文件?
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);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
String nameOfFile = URLUtil.guessFileName(myURL, null, MimeTypeMap.getFileExtensionFromUrl(myURL));
//request.setDestinationInExternalPublicDir(Environment.getExternalStorageDirectory().getPath() + "/KiiTTimeTableData/" + year + "/" + branch + "/" + section + "/", nameOfFile);
request.setDestinationInExternalPublicDir("/KiiTTimeTableData/" + year + "/" + branch + "/" + section + "/", nameOfFile);
DownloadManager manager = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
}
你將需要分析你下載的IMG標籤的HTML,並單獨下載圖像。或者使用一個庫來代替downloadmanager。 – alzee