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性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...