title: java.lang.SecurityException: Permission Denial: opening provider android.support.v4.content.FileProvider from ProcessRecord
body: <blockquote>
    <p>java.lang.SecurityException: Permission Denial: opening provider
    android.support.v4.content.FileProvider from ProcessRecord</p>
  </blockquote>
  
  <pre><code>&lt;provider
              android:name="android.support.v4.content.FileProvider"
              android:authorities="cn.cloudworkshop.miaoding.fileprovider"
              android:exported="false"
              android:grantUriPermissions="true"
              tools:replace="android:authorities"&gt;
              &lt;meta-data
                  android:name="android.support.FILE_PROVIDER_PATHS"
                  android:resource="@xml/file_paths"
                  tools:replace="android:resource"/&gt;
          &lt;/provider&gt;
  </code></pre>
  
  <p><strong>java code:</strong></p>
  
  <pre><code> @Override
      public void onReceive(Context context, Intent intent) {
          if (intent.getAction().equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
              Intent install = new Intent(Intent.ACTION_VIEW);
              Uri contentUri;
              if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.N) {
                  install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                  contentUri = FileProvider.getUriForFile(context, "cn.cloudworkshop.miaoding.fileprovider", file);
              } else {
                  contentUri = Uri.fromFile(file);
  
              }
              install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              install.setDataAndType(contentUri, "application/vnd.android.package-archive");
              context.startActivity(install);
          }
      }
  </code></pre>
  
  <blockquote>
    <p>install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)</p>
  </blockquote>
  
  <p>This code leads to this question,but I delete this code,this app will crash after installed.</p>