title: Android detect when DownloadManager has finished downloading
body: <p>Hi i'm downloading a file and i'm wanting to fire an ACTION_VIEW Intent once its finished downloading. so does anyone know how to detect when DownloadManager has finished.</p>
  
  <p>heres how i'm running DownloadManager</p>
  
  <pre><code>DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
  request.setTitle(filename);
  // in order for this if to run, you must use the android 3.2 to compile your app
  if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
   request.allowScanningByMediaScanner();
   request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
  
     }
  
  ContextWrapper c = new ContextWrapper(getBaseContext());
  String filePath = c.getFilesDir().getPath();
  request.setDestinationInExternalFilesDir(getBaseContext(), filePath, filename);
  
  // get download service and enqueue file
  DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
  manager.enqueue(request);
  Toast.makeText(getBaseContext(), "Downloading...", Toast.LENGTH_LONG).show();
  
  BroadcastReceiver onComplete = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
  
          String path = getFilesDir().getPath() +"/" + filename;
          File f = new File(path); 
          Intent myIntent = new Intent(Intent.ACTION_VIEW);
  
      myIntent.setData(Uri.fromFile(f));
          startActivity(myIntent);
      }
  };
  
  registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
  </code></pre>