9
我的应用程序下载大型zip文件(100mb +)。我正在使用默认的DownloadManager来帮助下载。 Google API文档建议注册一个BroadcastReceiver并监听ACTION_NOTIFICATION_CLICKED。我这样做,但我不知道如何从BroadcastReceiver内调用DownloadManager。如何从广播接收器启动下载管理器?
我想要做的事情基本上是浏览器的功能。当浏览器下载文件并且用户点击DownloadManager通知时,弹出DownloadManager窗口。我用什么意图来完成这个目标?
我的代码:
<receiver android:name="com.test.receiver.DownloadReceiver">
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"></action>
<action android:name="android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED" />
</intent-filter>
</receiver>
public class DownloadReceiver extends BroadcastReceiver {
private static final String tag = DownloadReceiver.class.getSimpleName();
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
*** code for unzipping removed ***
}
else if (DownloadManager.ACTION_NOTIFICATION_CLICKED.equals(action)) {
// Open the download manager
// BUT HOW???
}