Listen for updates and install updates from the server

  • First, I have server.I check to see if there is a new apk file that I download and try to install.
  • If the server has a new version of apk file , then I want to update my .apk file .
  • I want to install / upgrade without user interaction . Is it possible?
  • If user interaction is required, then how to install / update the .apk file.

I no longer have an idea about this.

  Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "jarviz.apk")), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 

But this does not work .WHen I am debugging, I do not see any error, but it does not install. How can i do this. Sorry for the bad english.

+7
source share
2 answers

I solved the problem this way.

 String vsName=Environment.getExternalStorageDirectory().getAbsolutePath()+"/download/"; File file = new File(vsName, "jarviz.apk"); System.out.println(":"+file); Intent install=new Intent(Intent.ACTION_VIEW); install.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(install); 
+5
source

Your code is almost correct, but you just created an intent. You still need to fire him to make any effect:

 startActivity(intent); 

and make sure that you have downloaded the jarviz.apk folder indeed in the download/ on the external storage, since you are referencing it in intention.

0
source

All Articles