我想在我的应用中下载文件。 我将此代码用于下载及其工作。
manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
String url = json_string_4_all[0];
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
id = manager.enqueue(request);
request.setDescription("درصد دانلود ");
request.setTitle("دانلود کتاب " + json_string_1_all[0]);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, json_string_1_all[0] + ".pdf");manager.enqueue(request);
我怎样才能成功下载?