下载完成后获取消息

时间:2014-05-27 12:41:35

标签: android android-download-manager

我试图在我的应用中使用 Android默认下载管理器,但问题是我的应用程序在下载完成后没有收到任何消息。 有没有办法解决这个问题?

1 个答案:

答案 0 :(得分:5)

您需要注册一个BroadcastReceiver才能知道它何时完成:

    registerReceiver(completionReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

接收者:

    BroadcastReceiver completionReceiver = new BroadcastReceiver() {
public void onReceive(Context ctxt, Intent intent) {

     //here You know the download is complete, do whatever You want to do
}
   };