http://blog.csdn.net/wa991830558/article/details/41014673
This is a relatively simple program, but there are many people on the Internet to ask this question, and the answer to the person, also did not fully answer the correct, and then there are many people to reprint the wrong answer, so that others use after the problem. How to download the new version of the file, here will not repeat, here to say the installation and open. /**
* Install APK file
*/
private void installapk () {
File Apkfile = new file (msavepath,constant.appfilename);
if (!apkfile.exists ()) {
Return
}
Installing the APK file via intent
Intent i = new Intent (Intent.action_view);
I.setflags (Intent.flag_activity_new_task);
I.setdataandtype (Uri.parse ("file://" + apkfile.tostring ()),
"Application/vnd.android.package-archive");
Mcontext.startactivity (i);
Android.os.Process.killProcess (Android.os.Process.myPid ());
}
If there is no android.os.Process.killProcess (Android.os.Process.myPid ()), the end is not prompted to complete, open.
If there is no I.setflags (intent.flag_activity_new_task), this step, finally installed, click Open, will not open the new version of the application.
Android for automatic upgrade and installation open