title: Android Install App: SecurityException: content://.fileprovider///Android/data/PK/files/Download/apk
body: <pre><code>Fatal Exception: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.VIEW dat=content://packageName.fileprovider///Android/data/packageName/files/Download/apkName typ=application/vnd.android.package-archive flg=0x10000001 cmp=com.google.android.packageinstaller/com.android.packageinstaller.PackageInstallerActivity } from ProcessRecord{f4e79d 20872:packageName/u0a207} (pid=20872, uid=10207) not exported from uid 10027
     at android.os.Parcel.readException(Parcel.java:2005)
     at android.os.Parcel.readException(Parcel.java:1951)
     at android.app.IActivityManager$Stub$Proxy.startActivity(IActivityManager.java:4386)
     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1615)
     at android.app.Activity.startActivityForResult(Activity.java:4569)
     at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
     at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:68)
     at android.app.Activity.startActivityForResult(Activity.java:4527)
     at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:751)
     at android.app.Activity.startActivity(Activity.java:4888)
     at android.app.Activity.startActivity(Activity.java:4856)
     at packagename.util.DownUtil.AndroidNInstallApk(DownUtil.kt:83)
     at packagename.util.DownLoadApkManager.isClearApk(DownLoadApkManager.kt:91)
     at packageName.util.DownLoadApkManager.startDownLoad(DownLoadApkManager.kt:49)
     at packageName.home.HomeFragment.downLoadApk(HomeFragment.kt:1429)
     at packagename.home.HomeFragment.access$downLoadApk(HomeFragment.kt:69)
     at packageName.home.HomeFragment$showForceUpdateDialog$1.onClick(HomeFragment.kt:1482)
     at android.view.View.performClick(View.java:6304)
     at android.view.View$PerformClick.run(View.java:24803)
     at android.os.Handler.handleCallback(Handler.java:790)
     at android.os.Handler.dispatchMessage(Handler.java:99)
     at android.os.Looper.loop(Looper.java:164)
     at android.app.ActivityThread.main(ActivityThread.java:6597)
     at java.lang.reflect.Method.invoke(Method.java)
     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:818)
  </code></pre>
  
  <p>：</p>
  
  <pre><code>val intentN = Intent(Intent.ACTION_VIEW)
  
      intentN.flags = Intent.FLAG_ACTIVITY_NEW_TASK
  
      val apkUri = FileProvider.getUriForFile(context,
              "${context.packageName}.fileprovider", file)
  
      intentN.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
      intentN.setDataAndType(apkUri, "application/vnd.android.package-archive")
      context.startActivity(intentN)
  </code></pre>
  
  <p>Resulting in：</p>
  
  <p>context.startActivity(intentN) </p>
  
  <blockquote>
    <p>Not all devices above Android N happen，Currently found on the Xiaomi 8 Android8.0.1 device</p>
  </blockquote>
  
  <p>What am I doing wrong ?</p>