Reputation: 1287
new apk
file I download this and try to install.new version of apk file
then I want to update my .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
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
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