我正在使用下载管理器从服务器下载文件 以及如何在下载管理器中添加进度下载?
DownloadPdf = (Button) findViewById(R.id.downloadpdf);
DownloadPdf.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File file = new File (Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS)+"/Pdf/" + "/" + name + ".pdf");
if (file.exists()) {
Toast.makeText(CatalogDetailActivity.this, "File Sudah ada", Toast.LENGTH_SHORT).show();
} else {
Download_Uri = Uri.parse(testing);
DownloadManager.Request request = new DownloadManager.Request(Download_Uri);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setAllowedOverRoaming(false);
// request.setTitle("Downloading");
request.allowScanningByMediaScanner();
//request.setDescription("Downloading");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
request.setVisibleInDownloadsUi(false);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "/Pdf/" + "/" + name + ".pdf");
refid = downloadManager.enqueue(request);
}
}
});
}