将数据发送到在DownloadManager中广播的BroadcastReciever?

时间:2016-04-08 05:52:58

标签: android broadcastreceiver

我使用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以便我可以在那里执行某些逻辑?

0 个答案:

没有答案