title: How to install an apk from inside an app?
body: <p>I placed an apk file called <code>longer_boost.apk</code> in the <code>res &gt; raw</code> directory of my app. I granted the app the <em>Install unknow apps</em> permission. But the following code isn't working.</p>
  <pre><code>if (getPackageManager().canRequestPackageInstalls()) {
  
      Uri apkUri = Uri.parse(&quot;android.resource://&quot; + getPackageName() + &quot;/raw/longer_boost&quot;);
  
      Intent intent = new Intent(Intent.ACTION_VIEW);
      intent.setDataAndType(apkUri, &quot;application/vnd.android.package-archive&quot;);
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
      try {
          getApplicationContext().startActivity(intent); //error is here
      } catch (ActivityNotFoundException e) {
          Log.e(TAG, e.getMessage());
      }
  }
  </code></pre>
  <p>I get the <code>ActivityNotFoundException</code> exception. It reads: &quot;No activity found to handle Intent&quot; and shows the intent.</p>