title: Download APK from url and execute
body: <p>I'm using the <code>DownloadManager</code> to download the apk from url. Download completes, I get the onReceive in my BroadcastReceiver for <code>DownloadManager.ACTION_DOWNLOAD_COMPLETE</code>.</p>
  
  <p>Some Coding: I download the apk file from an url to the download directory.</p>
  
  <pre><code>DownloadManager.Request r = new DownloadManager.Request(mUri);
  r.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "myapp.apk");
  r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
  DownloadManager dm = (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE);
  SharedPreferences mSharedPref = activity.getSharedPreferences("package", Context.MODE_PRIVATE);
  mSharedPref.edit().putLong("downloadID", dm.enqueue(r)).commit();
  </code></pre>
  
  <p>onReceive</p>
  
  <pre><code>File apkFile = new File(Environment.DIRECTORY_DOWNLOADS + "myapp.apk");
  Intent promptInstall = new Intent(Intent.ACTION_VIEW).setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
  startActivity(promptInstall);
  </code></pre>
  
  <p>Problems: </p>
  
  <ul>
  <li>The file is there, I want to execute it but I package-installer is not shown</li>
  <li>Even though I see the file in my phones download folder, I if I want to install it there is no package-installer to choose</li>
  <li>I'm not sure if I do the file and pathing stuff right..</li>
  <li>I get an parsing error from android when I try to open the file</li>
  </ul>
  
  <p>Someone got an idea please?</p>