title: How to get status of downloading?
body: <p>I use DownloadManager for getting status of downloading, but it still doesn't work, it never jumps to condition <code>if(c.moveToFirst())</code> and I don't know why. Could anybody help me, please?</p>
  
  <pre><code>private final BroadcastReceiver myReceiver = new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
              String action = intent.getAction();
  
              if(Intent.ACTION_SCREEN_OFF.equals(action)) {
  
                  DownloadManager downloadMgr = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
                  DownloadManager.Query query = new DownloadManager.Query();
                  query.setFilterByStatus(DownloadManager.STATUS_FAILED|DownloadManager.STATUS_PENDING|DownloadManager.STATUS_RUNNING|DownloadManager.STATUS_SUCCESSFUL);
                  Cursor c = downloadMgr.query(query);
                  if(c==null) {
                      //
                  }
                  else {
                      if(c.moveToFirst()) {
                          int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
                          int status = c.getInt(columnIndex);
                          if(status == DownloadManager.STATUS_RUNNING){
                          //do something
                          }
                      }
                  }
              }
          }
      };
  </code></pre>