Maidul
Maidul

Reputation: 1287

Listen for updates ans install from server

  1. First I have a server.I check server is there any new apk file I download this and try to install.
  2. If server have new version of apk file then I want to update my .apk file.
  3. I want to Install/update without user interaction.Is it possible?
  4. If user interaction is needed then How can I install/update .apk file.

I don't have idea much more about that.

 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 is not working.WHen I debugging I can not see any mistake but it does not install.How can I do that.Sorry for bad English.

Upvotes: 7

Views: 1441

Answers (2)

Maidul
Maidul

Reputation: 1287

I solved the issue 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);

Upvotes: 5

Marcin Orlowski
Marcin Orlowski

Reputation: 75629

Your code is almost correct but you just created the intent. You yet need to fire it to make any effect:

startActivity(intent); 

and make sure you download your jarviz.apk indeed to download/ folder on external storage as you refer to it in the intent.

Upvotes: 0

Related Questions