title: accessing a class from a BroadcastReceiver object
body: <p>I'm trying to add some code to an open source android download manager library, and I have encountered a problem. This code contains a class called DownloadManager that enables simultaneous downloads. Since I want my code to only download one file at a time, and keep the rest in a queue and pass it to the DownloadManager class as the earlier one has finished, I wrote my own class that extended the DownloadManager. I also had to write another class, MyReceiver, to receive on download complete broadcasts so I know when to start to download the next file in line. 
  The problem is I want to pass the next file once OnReceive() method has been called, but I do not have access to the properties of class DownloadManager. Plus, I can't create a new object of this class within my Receiver class as its constructor needs a ContentResolver object as an argument.</p>
  
  <p>Here is the code of my extended DownloadManager class:</p>
  
  <pre><code>public class MyDownloadManager extends DownloadManager {
      public ArrayList&lt;Request&gt; list;
      public boolean activeDownloadExists;
  
      public MyDownloadManager(ContentResolver resolver, String packageName) {
          super(resolver, packageName);
          list = new ArrayList&lt;DownloadManager.Request&gt;();
          activeDownloadExists = false;
  
      }
  
      public void addToWaitingList(Request request) {
          if (!activeDownloadExists) {
              enqueue(request);
              activeDownloadExists = true;
  
          } else
              list.add(request);
      }
  }
  </code></pre>
  
  <p>And this is the code of MyReceiver class:</p>
  
  <pre><code>public class MyReceiver extends BroadcastReceiver {
  
      public ArrayList&lt;Request&gt; list;
      public boolean activeDownloadExists;
      public IntentFilter filter;
  
      @Override
      public void onReceive(Context context, Intent intent) {
  
          Log.d("OnReceive" , "Received");
      }
  
  }
  </code></pre>
  
  <p>The open source I talked about is available here: <a href="https://github.com/yxl/DownloadProvider" rel="nofollow">https://github.com/yxl/DownloadProvider</a></p>