title: Android 7.0: install .apk
body: <p><strong>My Code:</strong> </p>
  
  <pre><code> public static void installApk(Context context, File apkFile) {
          Intent intent = new Intent(Intent.ACTION_VIEW);
          Uri uri = null;
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.N) {
              uri = FileProvider.getUriForFile(context, 
          context.getApplicationContext().getPackageName() + ".provider", apkFile);
  
              intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
          } else {
              uri = Uri.fromFile(apkFile);
              intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          }
          intent.setDataAndType(uri, "application/vnd.android.package-archive");
          context.startActivity(intent);
  
      }
  </code></pre>
  
  <p><strong>apkFile path:</strong></p>
  
  <blockquote>
    <p>/storage/emulated/0/Download/com.me.myapp-1.0.1.apk</p>
  </blockquote>
  
  <p><strong>Get Uri :</strong></p>
  
  <pre><code>content://com.me.myapp.provider/publicDir/Download/com.me.myapp-1.0.1.apk
  </code></pre>
  
  <p>The error I not get message.</p>