我使用DownloadManager下载文件并收听ACTION_DOWNLOAD_COMPLETE
以了解下载完成的时间。我以这种方式注册广播接收器:
<receiver android:name="my.path.DownloadCompleteReceiver" >
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
</intent-filter>
</receiver>
和BroadcastReceiver:
public static class DownloadCompleteReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
long id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
....
}
}
如何将额外数据发送到DownloadCompleteReceiver以便我可以在那里执行某些逻辑?