title: How to convert from Uri.fromfile to FileProvider.getUriForFile in Unity?
body: <p>I have a code from <a href="https://stackoverflow.com/a/45012767/3785314"><code>this</code></a> answer code in unity to install an apk but it does not work in Android 7.0 because <code>Uri.fromfile</code> is no longer supported and <code>FileProvider.getUriForFile</code> should now be used.</p>
  
  <p>I tried opening the project in android studio and followed this tutorial to manipulate the manifest file - <a href="https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en" rel="nofollow noreferrer">https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en</a></p>
  
  <pre><code>        AndroidJavaClass intentObj = new 
          AndroidJavaClass("android.content.Intent");
          string ACTION_VIEW = intentObj.GetStatic&lt;string&gt;("ACTION_VIEW");
          int FLAG_ACTIVITY_NEW_TASK = intentObj.GetStatic&lt;int&gt;
          ("FLAG_ACTIVITY_NEW_TASK");
          AndroidJavaObject intent = new 
          AndroidJavaObject("android.content.Intent", ACTION_VIEW);
  
          AndroidJavaObject fileObj = new AndroidJavaObject("java.io.File", 
          apkPath);
          AndroidJavaClass uriObj = new AndroidJavaClass("android.net.Uri");
          AndroidJavaObject uri = uriObj.CallStatic&lt;AndroidJavaObject&gt;
          ("fromFile", fileObj);
  
          intent.Call&lt;AndroidJavaObject&gt;("setDataAndType", uri, 
          "application/vnd.android.package-archive");
          intent.Call&lt;AndroidJavaObject&gt;("addFlags", FLAG_ACTIVITY_NEW_TASK);
          intent.Call&lt;AndroidJavaObject&gt;("setClassName", 
          "com.android.packageinstaller", 
          "com.android.packageinstaller.PackageInstallerActivity");
  
          AndroidJavaClass unityPlayer = new 
          AndroidJavaClass("com.unity3d.player.UnityPlayer");
          AndroidJavaObject currentActivity = 
          unityPlayer.GetStatic&lt;AndroidJavaObject&gt;("currentActivity");
          currentActivity.Call("startActivity", intent);
  </code></pre>