title: Phonegap Android app trigger update programmatically
body: <p>I am building an Android app that is hosted on a server outside Google Play. I need the app to check for new version and prompt user to update when the app starts.</p>
  
  <p>I built a mechanism to check for new version (the app checks for a file on server and compares version) which is working well. Then I prompt user to update, but if user chooses to proceed with the update, I'm not able to trigger the download and installation of the apk. </p>
  
  <p>I tried simply opening the apk url:</p>
  
  <pre><code>window.open(apkURL);
  </code></pre>
  
  <p>where the apkURL is the full http link to the .apk file hosted on server.</p>
  
  <p>But it doesn't seem to do anything.</p>
  
  <p>I've been researching but I don't find an answer on how to do this. I found some suggestions using native code, like this post <a href="https://stackoverflow.com/questions/4604239/install-application-programmatically-on-android">Install Application programmatically on Android</a> but I don't know how to do that from within my Phonegap app. </p>
  
  <pre><code>Intent promptInstall = new Intent(Intent.ACTION_VIEW)
  .setData(Uri.parse("file:///path/to/your.apk"))
  .setType("application/vnd.android.package-archive");
  startActivity(promptInstall); 
  </code></pre>
  
  <p>Is this the right way to trigger the update? How can something like this be done from within a Phonegap app? </p>
  
  <p>Thanks!</p>