KGillis KGillis - 1 year ago 113
Java Question

Launching .apk from Code

Intent install_intent = new Intent(Intent.ACTION_VIEW);
install_intent.setDataAndType(Uri.fromFile(new File(Environment
+ "app-release.apk")),

So, I am creating an application that checks for updates on launch. it downloads a file from a location, and then launches this intent to run the .apk. Unfortunately, when I do it, it gives me the error "there is a problem parsing the package android studio".

If I navigate to the download path, and run the .apk manually, it works just fine to install.

Any ideas?

Bun Bun
Answer Source

Try this one:

File apkFile = new File(Environment.getExternalStorageDirectory()
                  .getAbsolutePath() + "/app-release.apk");
Intent install_intent = new Intent(Intent.ACTION_VIEW);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download