title: How can I install an update on Android without google play?
body: <p>I've managed to download the latest version programmatically on the user's phone, now I'm trying to send an intent to request it to install it.</p>
  <p>I'm not using google play.</p>
  <p>Here's the code:</p>
  <pre><code>Intent intent = new Intent(Intent.ACTION_VIEW);
          intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + &quot;/&quot; + fileName)),
                  &quot;application/vnd.android.package-archive&quot;);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          ContextHolder.getInstance().getContext().startActivity(intent);
  </code></pre>
  <p>Here're the permissions in the manifest:</p>
  <pre><code>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;
  
  &lt;uses-permission android:name=&quot;android.permission.REQUEST_INSTALL_PACKAGES&quot; /&gt;
  
  &lt;uses-feature android:name=&quot;android.hardware.camera&quot; /&gt;
  &lt;uses-feature android:name=&quot;android.hardware.camera-autofocus&quot; /&gt;
  </code></pre>
  <p>I'm getting this error:</p>
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
  Process: ro.clinicasante.viator, PID: 12019
  android.os.FileUriExposedException: file:///storage/emulated/0/Download/app-debug-2.apk exposed beyond app through Intent.getData()
      at android.os.StrictMode.onFileUriExposed(StrictMode.java:2141)
      at android.net.Uri.checkFileUriExposed(Uri.java:2391)
      at android.content.Intent.prepareToLeaveProcess(Intent.java:11152)
      at android.content.Intent.prepareToLeaveProcess(Intent.java:11104)
      at android.app.Instrumentation.execStartActivity(Instrumentation.java:1722)
      at android.app.ContextImpl.startActivity(ContextImpl.java:1023)
      at android.app.ContextImpl.startActivity(ContextImpl.java:994)
      at android.content.ContextWrapper.startActivity(ContextWrapper.java:403)
      at ro.clinicasante.viator.network.FTPDownloadLatestVersion.onPostExecute(FTPDownloadLatestVersion.java:81)
      at ro.clinicasante.viator.network.FTPDownloadLatestVersion.onPostExecute(FTPDownloadLatestVersion.java:21)
      at android.os.AsyncTask.finish(AsyncTask.java:771)
      at android.os.AsyncTask.access$900(AsyncTask.java:199)
      at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:223)
      at android.app.ActivityThread.main(ActivityThread.java:7656)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
      I/Process: Sending signal. PID: 12019 SIG: 9
      Disconnected from the target VM, address: 'localhost:57651', transport: 'socket'
  </code></pre>
  <p>Any clue how I could solve it?</p>