Android for automatic upgrade and installation open

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.