title: No Activity Found to handle Intent (act=android.intent.action.VIEW) Trying to Install APK
body: <p>I'm trying to install an APK that I just downloaded. However, when I utilize the intent to install the APK I get error android.content.ActivityNotFoundException: No Activity found to handle Intent...
  Here's my source: </p>
  
  <pre><code>class DownloadTask extends AsyncTask&lt;String, Integer, String&gt; {
      private Context context;
      private String output;
      private Boolean install;
      private String file;
      private PowerManager.WakeLock wakeLock;
  
      public DownloadTask(Context context, String output, String file, Boolean install) {
          this.context = context;
          this.output = output;
          this.install = install;
          this.file = file;
      }
  
      @Override
      protected String doInBackground(String... surl) {
          InputStream input = null;
          OutputStream output = null;
          HttpURLConnection c = null;
          try {
              URL url = new URL(surl[0]);
              c = (HttpURLConnection) url.openConnection();
              c.connect();
              if (c.getResponseCode() != HttpURLConnection.HTTP_OK)
                  return "Server returned HTTP " + c.getResponseCode() + " " + c.getResponseMessage();
              int filelength = c.getContentLength();
              input = c.getInputStream();
              output = new FileOutputStream(this.output + this.file);
              byte data[] = new byte[4096];
              long total = 0;
              int count;
              while ((count = input.read(data)) != -1) {
                  total += count;
                  if (filelength &gt; 0)
                      publishProgress((int) (total * 100 / filelength));
                  output.write(data, 0, count);
              }
          } catch (Exception e) {
              return e.toString();
          } finally {
              try {
                  if (output != null) output.close();
                  if (input != null) input.close();
              } catch (IOException e) {
              }
              if (c != null) c.disconnect();
          }
  
          return null;
      }
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
          wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
          wakeLock.acquire();
          pDialog.show();
      }
  
      @Override
      protected void onProgressUpdate(Integer... progress) {
          super.onProgressUpdate(progress);
          pDialog.setIndeterminate(false);
          pDialog.setMax(100);
          pDialog.setProgress(progress[0]);
      }
  
      @Override
      protected void onPostExecute(String result) {
          wakeLock.release();
          pDialog.dismiss();
          if (result != null)
              Toast.makeText(context, "Download error: " + result, Toast.LENGTH_LONG).show();
          else if (this.install) {
              Intent intent = new Intent(Intent.ACTION_VIEW);
              intent.setDataAndType(Uri.parse("file://" + this.output + this.file), "application/vnd.android.package-archive");
              this.context.startActivity(intent);
          }
      }
  
  }
  </code></pre>
  
  <p>And here is the stacktrace of the error:</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.lastboxusa.lastboxinstaller, PID: 3076
                android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///data/data/com.lastboxusa.lastboxinstaller/kodi.apk typ=application/vnd.android.package-acrhive }
                    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
                    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
                    at android.app.Activity.startActivityForResult(Activity.java:3424)
                    at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
                    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
                    at android.app.Activity.startActivityForResult(Activity.java:3385)
                    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:856)
                    at android.app.Activity.startActivity(Activity.java:3627)
                    at android.app.Activity.startActivity(Activity.java:3595)
                    at com.lastboxusa.lastboxinstaller.MainActivity$DownloadTask.onPostExecute(MainActivity.java:136)
                    at com.lastboxusa.lastboxinstaller.MainActivity$DownloadTask.onPostExecute(MainActivity.java:59)
                    at android.os.AsyncTask.finish(AsyncTask.java:632)
                    at android.os.AsyncTask.access$600(AsyncTask.java:177)
                    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
                    at android.os.Handler.dispatchMessage(Handler.java:102)
                    at android.os.Looper.loop(Looper.java:136)
                    at android.app.ActivityThread.main(ActivityThread.java:5017)
                    at java.lang.reflect.Method.invokeNative(Native Method)
                    at java.lang.reflect.Method.invoke(Method.java:515)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>