相关疑难解决方法(0)

Android下载管理器已完成

关于android下载管理器的小问题.这是我第一次使用它并成功下载了多个文件并打开了它们.但我的问题是如何检查下载是否完成.

情况是我下载一个PDF文件并打开它,通常文件很小,它在打开之前完成.但是如果文件有点大,我如何在打开之前检查下载管理器是否完成了下载.

我如何下载:

Intent intent = getIntent();
DownloadManager downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
Uri Download_Uri = Uri.parse(intent.getStringExtra("Document_href"));
DownloadManager.Request request = new DownloadManager.Request(Download_Uri);

//Restrict the types of networks over which this download may proceed.
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
//Set whether this download may proceed over a roaming connection.
request.setAllowedOverRoaming(false);
//Set the title of this download, to be displayed in notifications.
request.setTitle(intent.getStringExtra("Document_title"));
//Set the local destination for the downloaded file to a path within the application's external files directory
request.setDestinationInExternalFilesDir(this,Environment.DIRECTORY_DOWNLOADS,intent.getStringExtra("Document_title") + ".pdf");
//Enqueue a new …
Run Code Online (Sandbox Code Playgroud)

android android-download-manager

45
推荐指数
3
解决办法
5万
查看次数

标签 统计

android ×1

android-download-manager ×1