
我正在使用DownloadManager类从服务器下载文件
这就是我在做的事情
public voID downloadpdf(String url, String sem, String Title, String branch) { Uri Download_Uri = Uri.parse(url); 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 (if enabled). request.setTitle("Downloading"); //Set a description of this download, to be displayed in notifications (if enabled) request.setDescription("Downloading file"); //Set the local destination for the downloaded file to a path within the application's external files directory request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, Title + "_" + branch + "_" + sem + "Year" + System.currentTimeMillis() + ".pdf"); //Enqueue a new download and same the referenceID downloadReference = downloadManager.enqueue(request);}事情是当下载完成后,如果用户点击通知它应该打开该文件我应该在此代码中做什么
broadcastReceiver onNotificationClick = new broadcastReceiver() { public voID onReceive(Context ctxt, Intent intent) { }};请帮忙
解决方法:
最后通过2行修复了这个问题
request.allowScanningByMediaScanner();request.setNotificationVisibility(DownloadManager.Request.VISIBIliTY_VISIBLE_NOTIFY_COMPLETED); 总结 以上是内存溢出为你收集整理的android – 使用下载管理器下载文件全部内容,希望文章能够帮你解决android – 使用下载管理器下载文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)