android – 如何从Broadcast Receiver发布下载管理器?

我的应用程序下载大型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???

    }

解决方法

找到我自己的答案.这是诀窍.
Intent dm = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS);
dm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(dm);

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...