这是我目前正在使用的代码
String iosjiUrl = "http://modapps.com/NotoCoji.ttf"; DownloadManager.Request request = new DownloadManager.Request(Uri.parse(iosjiUrl)); request.setDescription("Sscrition"); request.setTitle("Somle");// in order for this if to run, you must use the androID 3.2 to compile your app if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBIliTY_VISIBLE_NOTIFY_COMPLETED); } request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "Notocolorji.ttf");// get download service and enqueue file DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); manager.enqueue(request);
我无法找到让我等待文件下载的方法.
我也尝试弄清楚如何进行ASync,但无法想出来= =
再次感谢!
解决方法:
使用broadcastReceiver检测下载完成的时间:
public class DownloadbroadcastReceiver extends broadcastReceiver { @OverrIDe public voID onReceive(Context context, Intent intent) { String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) { //Show a notification } }}
并在您的清单中注册:
<receiver androID:name=".DownloadbroadcastReceiver"> <intent-filter> <action androID:name="androID.intent.action.DOWNLOAD_COMPLETE"/> </intent-filter></receiver>
总结 以上是内存溢出为你收集整理的android – 我怎么能等到DownloadManager完成?全部内容,希望文章能够帮你解决android – 我怎么能等到DownloadManager完成?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)